Help with from validation script

admin

Administrator
Staff member
Seems to be a common problem.

Couldn't find one I liked so here is my attempt but I keep getting this error... document.shopper.elements[...].value is null or not an object. :(

Please help




<Script>
var formOK

function checkField(field,pic) {
if (document.shopper.elements[field].value == '') {

document.images[pic].src = "images/error.gif";
formOK = false
}

function formCheck(theForm) {

// fields to validate
var fieldRequired = Array("PreApproved","Have you test-driven the car","New or Used Car","Make", "Model", "Year");
var fieldPic = Array("preapproved","testdrive","newUsed","make", "model", "year");


for (var i = 0; i < fieldRequired.length; i++){
checkField(fieldRequired,fieldPic)
}

if (formOK == false) {
alert ('Missing Info');
return false;
} else {
return true;
}
}

</script>
 
Back
Top