user460667
user460667

Reputation: 1940

JQuery DatePicker constrain to only valid dates?

I am currently using the JQuery datepicker, however it doesn't appear to enforce the input of only valid dates. Is this possible? For example, it will allow me to manually enter 22/22/22 into the date field. As a last result is it possible to only allow users to enter a date via the picker popup?

Thanks

Upvotes: 2

Views: 4677

Answers (2)

Naga Harish M
Naga Harish M

Reputation: 2789

try this ideas

<input type='text' id='date' readonly='true'>

or

$("#date").keypress(function(event) {event.preventDefault();});

or

$("#date").attr( 'readOnly' , 'true' );

more details here jQuery Datepicker with text input that doesn't allow user input

Upvotes: 1

betamax
betamax

Reputation: 14041

Try using the jQuery UI Datepicker Validation plugin. It works with the jQuery Validation plugin and provides the exact functionality you are asking for.

Upvotes: 3

Related Questions