我使用的自举日期选择在这里和引导验证这里.我也在使用bootstrap v3.1.1.
从datepicker中选择日期后,验证器不会做出反应.它只是在我使用键盘输入日期时才有效.
这是我的HTML代码:
在.js文件中我添加了:
$(document).ready(function () { $('.datepicker').datepicker(); )};
和验证人:
$(document).ready(function () { $('#myForm').bootstrapValidator({ feedbackIcons: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, fields: { endDate: { validators: { date: { format: 'DD/MM/YYYY', message: 'The format is dd/mm/yyyy' }, notEmpty: { message: 'The field can not be empty' } } } } }); });
Arkni.. 16
将BootstrapValidator与Bootstrap-datetimepicker或Bootstrap-datepicker一起使用时,应重新验证日期字段.
所以你应该添加这个:
1)使用bootstrap-datetimepicker:
$('.date') .on('dp.change dp.show', function(e) { // Revalidate the date when user change it $('#myForm').bootstrapValidator('revalidateField', 'endDate'); });
2)使用bootstrap-datepicker:
$('.datepicker') .on('changeDate show', function(e) { // Revalidate the date when user change it $('#myForm').bootstrapValidator('revalidateField', 'endDate'); });
有关更多信息,请参阅datetimepicker示例.