All,
I have a regular expression (below) and I’m walking through a entire web form (say there are 10 elements). I only want to print the alert message if the form name matches one of the three below(REQUIRED_<something). But, my problem is the alert message is printing every element in the form.
So, there must be something wrong with the “if” statement. I’ve tried several things and nothing seems to work. It seems the if statement always returns true no matter what the name of the element is.
Very lost.
Any thoughts ??
var q = thisform.elements;
for ( i = 0; i < q.length; i++ ) {
if (/^[REQUIRED_AgendaName|REQUIRED_TestListName|REQUIRED_ProcedureName]$/.test(q[i].name) ) {
alert(‘called ‘ + q[i].name); // debugging
if (/[‘”,]+|^s+|s+$/.test(q[i].value )) {
alert(msg);
q[i].focus();
q[i].select();
return false;
}
}
}