John S
John S

Reputation: 8341

Validation of date input into textbox when using JQueryUI Datepicker

I have a textbox that I've attached the datepicker to. If the user enters the date via the datepicker all is well but they also have the ability to go in and enter a bad date directly into the textbox. i.e. 1/55/1995 Can the text box be disabled so only the calendar can be used?

How are people preventing this?

Upvotes: 2

Views: 3105

Answers (2)

Sandip.Nascar
Sandip.Nascar

Reputation: 335

You can validate the input text, if entered manually to the textbox.

Have a look at the url below, http://keith-wood.name/uiDatepickerValidation.html

Hope this helps.

Cheers

Upvotes: 1

asymptoticFault
asymptoticFault

Reputation: 4529

Looks like what you need is to just disable the field or make it readonly. Check out this answer How can I disable all keyboard keys?

I would say readonly is the better option because it still allows the value to be retrieved when it is posted back; don't think disabled fields get picked up.

Upvotes: 1

Related Questions