Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $("#userForm").validate({
- //rules basically define rules on your input fields.You can put different rules based on your requirement and availability(which you can check in jQuery validation documentation).
- rules:{
- userName:"required",
- password:"required",
- confirmPassword:"required",
- dateOfBirth:"required",
- gender:"required"
- },
- //messages are map to inputs and will be present if user violates any of the rule.
- messages:{
- userName : "UserName is a required field.",
- password : "Password is a required field.",
- confirmPassword : "Please enter same as confirmPassword.",
- dateOfBirth : "Date of Birth is a required field.",
- gender : "Gender is a required field."
- },
- //submitHandler handles task which we can perform after successful validation.
- Like below after successful validation I'm adding action attribute to my form and submitting it.
- submitHandler:function(){
- $('#userForm').attr( { action: $('#actionMainURL').val() } );
- $('#userForm').submit();
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement