R J.
R J.

Reputation: 1542

How to restrict future date using Jquery

I am using date picker in my application which should not allow user to select future date.

I could not find any function in jquery . Please give some suggestions.

I am using html 5 date input type.

<input type="date" name="bday">

Upvotes: 1

Views: 771

Answers (3)

Fseee
Fseee

Reputation: 2627

Try something like this:

<input id="yourOwnId" type="date" name="bday">

Then with jquery and UI datepicker plugin for example if your future date is today:

$("#yourOwnId").datepicker({
       dateFormat : 'dd/mm/yy',
       maxDate : '12/10/2012
});

Or simply according to ThiefMaster:

maxDate: 0

Upvotes: 2

George Reith
George Reith

Reputation: 13476

Even though the question is extremely vague have a look at http://api.jqueryui.com/datepicker/#option-maxDate.

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318658

Assuming you are using the jQuery UI Datepicker what you are looking for is the maxDate option. By setting it to 0 you can disallow any dates in the future.

Upvotes: 0

Related Questions