wasim kazi
wasim kazi

Reputation: 378

Using custom validation jQuery with submitHandler

I have on problem with custom validation.

I made one form which post data to some function before it post there is some custom validation rule I made and then I call submitHandler but that's not working.

 $(document).ready(function(){
$("#faculty").validate({
    rules: {
        designation:  {
         required: true
              },

     faculty_qual: {
          required: true
        }
      },

  messages: {
      designation: 'Please select a Dasignation.',  
      faculty_qual: 'Please select qualification'
    }
   submitHandler: function(form) {
       create_faculty();
         }
   });

Now when I run this I got some error Uncaught SyntaxError: Unexpected identifier

Now how will I send this data with this custom validation.

Upvotes: 0

Views: 582

Answers (1)

Juri
Juri

Reputation: 32910

Seems like a syntactic error. You are missing a colon after the messages object and a semicolon and a parenthesis and semicolon at the end of the validate function invocation.

$(document).ready(function(){
    $("#faculty").validate({
       rules: {
          designation:  {
            required: true
          },

          faculty_qual: {
            required: true
          },
          matric_pass_year: {
             required: true
      }
       },
       messages: {
          designation: 'Please select a Dasignation.',  
          faculty_qual: 'Please select qualification',
          matric_pass_year: 'Please select Year' 
       },
       submitHandler: function(form) {
         create_faculty();
       }
   });
});

Upvotes: 3

Related Questions