如何在jquery中验证datepicker日期

时间:2016-10-03 03:25:41

标签: javascript jquery codeigniter

<div class="input-group date date-picker" data-date-format="yyyy-mm-dd">
<input type="text" class="form-control" readonly name="start" required>
<span class="input-group-btn"><button class="btn default" type="button" >
<i class="fa fa-calendar"></i></button></span> </div>

如何创建验证datepicker bootsrap?

1 个答案:

答案 0 :(得分:0)

您可以像这样验证日期选择器:

$(document).ready(function(){
    $("#datepicker").datepicker();
    $("#datepicker").blur(function(){
        val = $(this).val();
        val1 = Date.parse(val);
        if (isNaN(val1) == true && val !== ''){
           alert("error");
        }
        else{
           console.log(val1);
        }
    });
});

Working fiddle