View Full Version : getting the cursor back in a particular form field
hendryk
08-27-2002, 05:34 PM
Hi,
I have a function that makes sure particular form fields have something entered in them. After the alert message appears how do I get the cursor back in the field where the error occurred rather than let the user find it. The field names are all in an array in this function.
Thanks
Katie
requestcode
08-27-2002, 05:56 PM
Not seeing your code I can't give you an exact answer, but this bit of code should give you an idea:
document.form_name.field_name.focus()
If you could post your code here we could probably give you a better answer.
hendryk
08-27-2002, 06:04 PM
Here is the code:
for (i = 0; i<fieldArray.length;i++)
{
field =eval("aform." + fieldArray[i]);
if(field.value =="")
{
fieldName = userNames[i];
decision = false;
break;
}
}
for (i = 0; i<combo.length;i++)
{
field = eval("aform." + combo[i]);
if(!checkComboBox(field))
{
fieldName = comboUser[i];
decision = false;
break;
}
}
if (!decision){alert(fieldName + " is a required field. Please enter a value.");}
else { aform.submit(); prompt = "The form is being submitted.";alert(prompt);}
}
i didn't include the array of field names - they are quite long.
requestcode
08-27-2002, 06:19 PM
I have not tested this, but try this:
if (!decision){alert(fieldName + " is a required field. Please enter a value.");field.focus();}
else { aform.submit(); prompt = "The form is being submitted.";alert(prompt);}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.