Set UI Focus on the First Field of a Form


How do I set the focus to the first form field?

✍: FYIcenter


You cannot do this with HTML. However, you can include a JavaScript after the form that sets the focus to the appropriate field, like this:

    <input type="text" id="myinput" name="myinput" ...>

<script type="text/javascript"> document.myform.myinput.focus(); </script>

2007-03-03, 5618👍, 0💬