Focus on blank entry

admin

Administrator
Staff member
The below checks for blank entries in my form but how do I make it focus to the field if it is found to be blank? I tried "focus()" but that doesnt work.

if(document.stand.field1.value == "")
{
alert("Fill in Field1 value");
focus();

}

if(document.stand.field2.value == "")
{
alert("Fill in Field2 value");
focus();
}
 
Back
Top