Currently, I am using some javascript validation code for an INPUT as below:
And I call it like this:
What I need help with is getting the same validation check to be done onSubmit BEFORE the page is sent. If validation fails, the form is not submitted. If at all possible, I would like to make sure it won't blow out the values that the user has already put into the form because my form has 24 fields.
Any suggestions would be great.
function valuevalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
And I call it like this:
Percentage Interest <INPUT class=cf_inputbox id=text_3 maxLength=5 size=5 name=text_3 onChange="valuevalidation(this,0,100,'Interest must be between 100 and 0');">%
What I need help with is getting the same validation check to be done onSubmit BEFORE the page is sent. If validation fails, the form is not submitted. If at all possible, I would like to make sure it won't blow out the values that the user has already put into the form because my form has 24 fields.
Any suggestions would be great.