Oh, the PHP validation part is easy 🙂 BUT, I have to validate both ways, JavaScript first, then catch those with JavaScript disabled with the PHP. However, I did find a resolution:
function ValAdd(vForm) {
var numEmp = vForm.numEmp.value;
var first, last, i = 1, focus_me = null, msg = '';
while (first = vForm.elements['first' + i]) {
last = vForm.elements['last' + i];
if (/^\s*$/.test(first.value) || /^\s*$/.test(last.value)) {
msg += '\nEmployee #' + i;
if (focus_me == null)
focus_me = (/^\s*$/.test(first.value)) ? first : last;
}
++i;
}
if (msg != '') {
msg = 'Please complete the following entries:\n' + msg + '\n\nThank you.';
alert(msg);
if (focus_me) focus_me.focus();
return false;
} else {
return true;
}
}
No credit to me. I got this solution from the same question on SitePoint. I was trying to mix PHP and JavaScript and it just wasn't working. I figured out that it was a straight JavaScript issue before I got my answer.