function validate_form(thisform)
{with (thisform)
{if (validate_required(firstname,"msg!")==false)
{firstname.focus();return false}
else if (validate_required(lastname,"msg!")==false)
{lastname.focus();return false}
else if (validate_required(address,"msg!")==false)
{address.focus();return false}
else if (validate_required(area,"msg!")==false)
{area.focus();return false}
else if (validate_required(city,"msg!")==false)
{city.focus();return false}
else if (validate_required(postalcode,"msg!")==false)
{postalcode.focus();return false}
}
}
But i also want to check if the telephone number is in 10-digit form, and i add the following:
function validate_required_tel(field,alerttxt)
{with (field)
{
if (field.value.length!="10")
{alert(alerttxt);return false}
else {return true}
}
}
function validate_form(thisform)
{with (thisform)
{
if (validate_required_tel(cellphone,"msg!")==false)
{cellphone.focus();return false}
}
}
My problem is that any of the two scripts works fine on it's own, but when used together (in the same validation.js page) the first controls are skipped, and only the telephone control works.
thats because you can't have two functions of the same name and expect them both to work. Best thing to do is to add the extra code to the first function.
Bookmarks