Beginner form validation



Can someone look at this code and tell me what is wrong? The error
message says "Line 8 Char 1 'dealerId' is undefined" But I thought that
I stated everything correctly. Do I have any syntax errors in here. The
code is supposed to display an alert if someone typed in letters
instead of numbers for each input box.
---------------------------------------------------------------------------------------------------------------------------------------

<script>
function validateInputs() {
var validInputs=(IsValidNumber(dealerId,DealerID)
&&IsValidNumber(seriesId,SeriesID)
&&IsValidNumber(modelId,ModelID)
&&IsValidNumber(extColorId,ExteriorColorID)
&&IsValidNumber(fabricTypeId,FabricTypeID));
if(!validInputs){
return false;
}
}
function IsValidNumber() {
var input = document.getElementById(inputId);
if(!validateNumber(input,inputDescription)){
return false;
}else{
return true;
}
}

var re = /^\d+$/;
function validateNumber(input, inputName) {
var validNumber = re.exec(input.value);

if (!validNumber) {
alert("Input a valid number in " + inputName + " now!");
input.focus();
return false
} else {
return true;
}
}
</script>

html:
<form id="Form1" action="DisplayMultipleProcedures.aspx" method="post"
onsubmit="return validateInputs();">
---------------------------------------------------------------------------------------------------------------------------------------

Thanks :)

.



Relevant Pages

  • Re: Beginner form validation
    ... function validateInputs() { ... var validInputs= ... var input = document.getElementById; ... var validNumber = re.exec; ...
    (comp.lang.javascript)
  • Re: Why does this code not work?
    ... evtobj.charCode: evtobj.keyCode var ... Line endings do matter in JavaScript. ... What you have now is a collection of syntax errors. ... debugging harder, and it won't reduce the document size much either ...
    (comp.lang.javascript)