This is a crazy question but I have been going nuts trying to solve my dilemna. I have a form that posts to submit.php. Before the form posts I would like to check the fields for blanks and stop the form from submitting using a simple javascript code that works great. Here is my problem!
The field names are info[name] and are not recognized by the javascript. The submit.php needs the names to be this way and I was hoping for a work around.
Here is what a field looks like:
<INPUT name=info[Phone] size=”20″ value=”<? echo $phone; ?>”>
I tried changing the name to be inside quotes but it still doesn’t work.
Here is a portion of the code that isn’t working:
function frmLifeStyle_Validator(theForm)
{
if (theForm.info[Fname].value == “”)
{
alert(“Please enter a value for the “First Name” field.”);
theForm.info[Fname].focus();
return (false);
}
if (theForm.info[Fname].value.length > 50)
{
alert(“Please enter at most 50 characters in the “First Name” field.”);
theForm.info[Fname].focus();
return (false);
}
Is there anyway to get the names of the fields to work this way?