I have a form with 42 text cells that are all being validated by the same script. If the proper time format isn’t entered, it properly detects it and says so. Each cell is passing its id to the script.
Where I’m running into trouble is in trying to put focus back on the offending cell when the data is not formatted properly.
How do I properly format a variable name in:
document.formname.variable.focus()
function timecheck(id) {
var pattern = “^((
var input = document.getElementById(id).value;
if (input.match(new RegExp(pattern)))
{
}
else
{
window.alert(“Please use a proper time format such as 9:15 AM or 12:30 PM”);
//need to focus here
}
}