Created
June 22, 2015 06:53
-
-
Save yoonwaiyan/51a370fbcdf057a5ed34 to your computer and use it in GitHub Desktop.
Bootstrap 3 with jQuery Validation
This file contains hidden or 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
$.validator.setDefaults({ | |
errorElement: "span", | |
errorClass: "help-block", | |
highlight: function (element, errorClass, validClass) { | |
$(element).closest('.form-group').addClass('has-error'); | |
}, | |
unhighlight: function (element, errorClass, validClass) { | |
$(element).closest('.form-group').removeClass('has-error'); | |
}, | |
errorPlacement: function (error, element) { | |
if (element.parent('.input-group').length || element.prop('type') === 'checkbox' || element.prop('type') === 'radio') { | |
error.insertAfter(element.parent()); | |
} else { | |
error.insertAfter(element); | |
} | |
} | |
}); |
This file contains hidden or 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
<div class="form-group"> | |
<div class="col-lg-12"> | |
<div class="checkbox"> | |
<label id="LabelConfirm" for="CheckBoxConfirm"> | |
<input type="checkbox" name="CheckBoxConfirm" id="CheckBoxConfirm" required="required" /> | |
This is the example input | |
</label> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment