Is it possible to use the JQuery Validation to validate the Bootstrap Datepicker? As it doesn't expose the input
field, I can't get it to validate.
Example: https://jsfiddle.net/Khrys/2rcr9j5s/
$.validator.setDefaults({
submitHandler: function() {
form.submit()
}
});
$().ready(function() {
var container = $('div.containerx');
$("#Form").validate({
ignore: [],
messages: {
StartTime: {
required: "Select the StartTime."
}
},
errorContainer: container,
errorLabelContainer: $("span", container),
highlight: function ( element, errorClass, validClass ) {
$('#StartTime').addClass( "btn-danger" );
$('#Filter').addClass( "btn-danger" );
},
unhighlight: function ( element, errorClass, validClass ) {
$('#StartTime').removeClass( "btn-danger" );
$('#Filter').removeClass( "btn-danger" );
}
});
});
Update:
Class btn-danger
needs to be applied to the element correctly.