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
    Regular Coder
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    120
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Need Help Validation Not Working.

    Ho do I get my custom validation form working on codeigniter I don't want to uses there default one for some reason when I add it will not pick up when I click submit button still sends. I have it working on here http://codepen.io/CarraraWebsiteSolutions/pen/rIALo but will not work on codeigniter I have all jquery and ajax files.

    Code:
    <script type="text/javascript">
    /* Bootstrap Contact Form"
    ***************************************************************************/
    
    $(document).ready(function(){
      
    // validate signup form on keyup and submit
      //jQuery.validator.addMethod("phoneAus",function(a,b){return this.optional(b)||a.length>14&&a.match(/^[0-9]{10}$|^\(0[1-9]{1}\)[0-9]{8}$|^[0-9]{8}$|^[0-9]{4}[ ][0-9]{3}[ ][0-9]{3}$|^\(0[1-9]{1}\)[ ][0-9]{4}[ ][0-9]{4}$|^[0-9]{4}[ ][0-9]{4}$/)},"Please specify a valid mobile number");
      
    jQuery("#email").validate({
        
    highlight: function(element) {
      $(element).parent('div').addClass('has-error');
    },
      
    unhighlight: function(element) {
      $(element).parent('div').addClass('has-success');
    },
      
    rules: {
      
    name: {
       required: true
    },
          
    email: {
      required: true
    },
      
    subject: {
      required: true
    },
      
    message: {
      required: true,
      minlength: 15
    }
    
    },
      
    messages: {
          
    name: {
      required: 'Please enter your name.'
    },
        
    email: {
      required: 'Please enter a valid email address.',
      minlength: 'Please enter a valid email address.'
    },
          
    subject: {
      required: 'You need to enter a subject.'
    },
        
    message: {
      required: 'You need to enter a message.',
      minlength: 'Enter at least {15} characters.',
      maxlength: 'Enter at least {5000} characters.'
    }
    
    },
      
    });
    });
    </script>

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,919
    Thanks
    6
    Thanked 1,040 Times in 1,013 Posts
    I have no idea how to debug JS in these online parsers since it messes up Firebug but put debug: true into the validate options and see what your console is saying (if anything).


  •  

    Tags for this Thread

    Posting Permissions

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