Beginner form validation
- From: "Jessica" <Jessica.Sexton@xxxxxxxxxxxxxxxxxx>
- Date: 31 May 2006 13:59:06 -0700
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 :)
.
- Follow-Ups:
- Re: Beginner form validation
- From: Dag Sunde
- Re: Beginner form validation
- From: David Dorward
- Re: Beginner form validation
- Prev by Date: Re: Accessing pseudo-classes through Javascript (Jscript)
- Next by Date: Re: Accessing pseudo-classes through Javascript (Jscript)
- Previous by thread: Seek ideas for AJAX listing of names
- Next by thread: Re: Beginner form validation
- Index(es):
Relevant Pages
|