我正在尝试使用bootstrap validator验证date range
。
问题是我需要使用变量动态指定min
和max
条件。
这是我做过但失败了。不知道如何使用变量来指定bootstrap验证器中的范围?
<?php
$min_date = "2014-02-01";
$max_date = "2014-02-28";
?>
<script>
jQuery(document).ready(function($) {
var min_date = '<?php echo $min_date; ?>'; <-- This works! Thank you Dennis!
var max_date = '<?php echo $max_date; ?>'; <-- This works! Thank you Dennis!
$('#form')
.bootstrapValidator({
feedbackIcons: {
validating: 'glyphicon glyphicon-refresh'
},
fields: {
'date': {
validators: {
notEmpty: {
message: 'Required'
},
date: {
message: 'The date is not valid',
format: 'YYYY-MM-DD',
min: min_date, <-- this does not work
max: max_date <-- this does not work
//min: '2014-02-01', <-- this works
//max: '2014-02-28' <-- this works
}
}
}
});
</script>