简体   繁体   中英

how to validate datepicker date in jquery

<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>

how to create validate datepicker bootsrap?

You can validate your datepicker like this:

$(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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM