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();

Like this post? Please share:

Follow @liewcf on Twitter; Join Facebook page; Subscribe to free newsletter for updates like this article..

  • Anonymous

    :evil:

  • Anonymous

    :evil:

t