JavaScript: Focus and Select Field

Filed in: Web Development — April 5th, 2004

 

Use: Simple JavaScript to make pointer to jump to selected field and select all content in it. Good to use in form validation.

Compatibility: Tested on Internet Explorer(IE) 6.0 and Mozilla 1.6. Should work for IE4+ and Netscape 4+

Code:

document.form1.field1.focus();
document.form1.field1.select();

Read also:

  • Anonymous
    :evil:
blog comments powered by Disqus