Created
March 23, 2016 07:05
-
-
Save walteryu/e360c736dfdfccea8e07 to your computer and use it in GitHub Desktop.
DWA-15, P3: jQuery Form Validation Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery script for validating user input | |
$(document).ready(function () { | |
$('#random-user').append("Form submitted successfully!"); | |
$('#random-user').validate({ | |
// initialize jquery validation plugin | |
rules: { | |
count: { | |
required: true | |
}, | |
add_email: { | |
required: true | |
} | |
add_address: { | |
required: true | |
} | |
} | |
highlight: function (element) { | |
$(element).closest('.form-group').removeClass('success').addClass('error'); | |
}, | |
success: function (element) { | |
element.text('Form submitted successfully!').addClass('valid') | |
.closest('.form-group').removeClass('error').addClass('success'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And here is the random-user HTML form: