Friday 15 January 2010

jquery validation plugin not firing at all -


I am using the jquery validation plugin on an existing form but it is not firing when submitting it.

In the browser I have not found any javascript errors, but nothing is happening and the form is being collected, which should not be.

Here is the code:

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "// ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> & Lt; Script src = "http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js></script> & lt; script type =" text / javascript "& gt; ; $ (). Ready (validate the function () {// comment form when it is deposited $ ("# registration form"). Validate the signup form on valid (); // keyboard and $ (" Submit (Valid: {Provision: {Full Name: {Required: true, Minimalmpi: 2, Maxlemth: 50}}, Message: {Full name: {Required: "Please enter a name", min Lambon: "Your name should be at least 2 characters", Maxlength: "Your name should not be more than characters"}}}}}}};   gt ;  & Lt; / Tr & gt; & Lt; / T enabled & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

Why is there no valid recognition on submission?

Found the problem.

I can not have two legitimate works. From the demo I tried to validate the form on both submission and key, but I did not have to do this as both keyboard recognition.

To do this, I remove the line above <> $ ("# registrationform") pre-validated () .;

This is not working because .validate () Prevents any subsequent example because there are no options defined in your first example, then the plug-in is initialized without any rule or option, and the second example is completely ignored.

  $ ("# registration"). ; // & lt; - Delete this line $ ("# Registration Form"). Validate ({// your rules and options});   

In addition, it is not recommended ...

  $ (). Ready (function () {  

Change it to more standard ...

  $ (document) .ready (function () {  

For a more efficient code, you can use it in place of minlength and maxlength .

  minlength: 2, maximum length: 50   

and it can be written as simply ...

  categorization: [2, 50]    

No comments:

Post a Comment