If you like SEOmastering Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

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

Started by chinmay.sahoo, 01-31-2017, 08:07:27

Previous topic - Next topic

chinmay.sahooTopic starter

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

<form id="myform" name="myform" action=...> <input type="text" id="myinput" name="myinput" ...> </form>
<script type="text/javascript"> dоcument.myform.myinput.focus();</script>

A similar approach uses <body onload=...> to set the focus, but some browsers seem to process the ONLOAD event before the entire dоcument (i.e., the part with the form) has been loaded.



If you like SEOmastering Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...