...

View Full Version : frmvalidator.addValidation function



midohioit
12-19-2006, 04:37 PM
<form action="http://www.midohioit.com/quote/quote.php" enctype="multipart/form-data" method="post" name="quoteform" id="quoteform">
..........

<script language="JavaScript" type="text/javascript">

var frmvalidator = new Validator("quoteform");

frmvalidator.addValidation("name","req","Please enter your Name");
frmvalidator.addValidation("name","maxlen=50","Maximum length for Name is 50 characters.");
frmvalidator.addValidation("name","minlen=3","Minimum length for Name is 3 characters.");
frmvalidator.addValidation("name","alphanum");

frmvalidator.addValidation("company2","req","Please enter your Company Name");
frmvalidator.addValidation("company2","maxlen=50","Maximum length for Company Name is 50 characters.");
frmvalidator.addValidation("company2","minlen=3","Minimum length for Company Name is 3 characters.");
frmvalidator.addValidation("company2","alphanum");
frmvalidator.addValidation("budget","dontselect=0","Please select a range for your Budget.");


//following line does not work
//frmvalidator.addValidation("designtype1","checked","Please check as least one box for the Work needed area." );

</script>

......
.........

</form>

I am having problems getting the frmvalidator.addValidation function to work for a checkbox is there a way I can just use the existing frmvalidator.addValidation function for a checkbox??

:confused:

j9ine
12-19-2006, 08:48 PM
You can add a custom validation for checkboxes as in the code below. Check out the link below for a complete list of validation descriptors.

http://www.javascript-coder.com/html-form/javascript-form-validation.phtml



function DoCustomValidation()
{
var frm = document.forms["quoteform"];
if(!frm.designtype1.checked)
{
alert('The checkbox is not checked!');
return false;
}
else
{
return true;
}
}

frmvalidator.setAddnlValidationFunction("DoCustomValidation");



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum