是否可以使用JQuery Validation来验证Bootstrap Datepicker?由于它没有暴露这个input
领域,我无法让它验证.
示例: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" ); } }); });
更新:
类btn-danger
需要正确地应用于元素.
https://jsfiddle.net/2rcr9j5s/4/