faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

How can i set focus to a control after a message box is displayed

Apr 9th, 2008 20:20
ha mo, Dave Clark, Mahesh,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mahesh,
     The following is pretty much a standard for form field 
validations which return an error message:
function FieldIsEmpty(fld)
{
  if (/^\s*$/.test(fld.value)
  {
    alert('This field is required.');
    if (fld.select) fld.select();
    if (fld.focus) fld.focus();
    return false;
  }
  return true;
}
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.healthinhealth.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com