Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

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


  • #2
    New Coder
    Join Date
    Nov 2006
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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");


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •