简体   繁体   中英

how to disable past date on date picker

$('input[name="event_startdate"]').datepicker({
    format: 'yyyy-mm-dd'
    startDate: new Date()
});

The above is my code. It displays the error: "Uncaught SyntaxError: Unexpected identifier"

you forgot comma(,) between format: 'yyyy-mm-dd' and startDate: new Date()

Or

Try This

For css Class -

$('.datepicker').datepicker({ format: 'yyyy-mm-dd', startDate: new Date() });

here .daterpicker is a class name appiled on input control

For ID -

$('#datepicker').datepicker({ format: 'yyyy-mm-dd', startDate: new Date() });

here #daterpicker is a class name appiled on input control

You can try like this.

 $('input[name="event_startdate"]').datepicker({ format: 'yyyy-mm-dd', minDate:"0" });

in html

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
<link data-require="jqueryui" data-semver="1.10.0" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/css/smoothness/jquery-ui-1.10.0.custom.min.css" />
<link rel="stylesheet" href="style.css" />
<script data-require="jquery" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<script data-require="jqueryui" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/jquery-ui.js"></script>
<script src="script.js"></script>
</head>

<body>
<input type="text" name="event_startdate">
</body>

</html>

here is plunker : https://plnkr.co/edit/nSbc4nJqU2VgvNZzrhMt?p=preview

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