I wanted to learn form validation and tried spending a few hours and came up with the below code ... when I was going through a tutorial .,
Started with an expectation : If the field has valid values the field should be highlighted , and it should have a tick glyphicon else if the values of the filed is wrong it should highlight the textbox/field in red and throw up a validation error message.
But when I tried doing the same I came could only see the error message for form validation.
Please help me with this code .
Glyphicon and highlight to the textbox was not happening.
Link to my js fiddle code snippet
below is the JS code which I got it from the tutorial
Thanks :)
$(document).ready(function(){
$('#contact-form').validate({
rules: {
name: {
minlength: 2,
required: true
},
},
highlight: function(element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function(element) {
element
.text('OK!').addClass('valid')
.closest('.control-group').removeClass('error').addClass('success');
}
});
});