I have two date fields on my Visualforce page and on occasions the datepicker/calendar pops up upon page load. I understand one way to prevent this is to use javascript as suggested below:

<input id="hiddenElementId" type="hidden" />
<script type="text/javascript">
window.onload = setFocus
function setFocus()


However this post is pretty old now, is this still considered the best way to do this?


1 Answer 1


Please include the snippet below after the page tag.

    <script>function setFocusOnLoad() {}</script>
    <!-- further content -->

Hope this will work for you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .