Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-19-2006, 03:37 PM   PM User | #1
midohioit
New to the CF scene

 
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
midohioit is an unknown quantity at this point
frmvalidator.addValidation function

<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??

midohioit is offline   Reply With Quote
Old 12-19-2006, 07:48 PM   PM User | #2
j9ine
New Coder

 
Join Date: Nov 2006
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
j9ine is an unknown quantity at this point
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...lidation.phtml

Code:
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");
j9ine is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:24 PM.


Advertisement
Log in to turn off these ads.