I’m adding some javascript validation to a form. The form has fields that currently look like:
<input name="Employee Full Name" value="" type="text" id="Employee Full Name" size="30" maxlength="50" style="width:300px;">
I am trying to access the values of the fields, but I seem to be doing it incorrectly with the spaces in the input name, is there a way to escape?
if (theForm.Employee Full Name.value == ""){
alert("Please enter a value for the \"Employee Full Name\" field.");
theForm.Employee Full Name.focus();
return (false);
}
You can use the bracket notation for objects as well as arrays:
This allows you to access attributes where the names are invalid in a
.notation syntax: