jQuery date picker widget

Looking for a jQuery based date calendar widget that can be tied to a text box on a form. I am using https://api.jqueryui.com/datepicker/

It either lacks the functionality to prevent user from typing in gibberish as a date or I don't know how to configure it properly. I tried this:

$(function() {
			constrainInput: true}););

Open in new window

I thought constrain input required a format mm/dd/yy (or whatever you pick as the default format). Constructed as in the code, it disables the functionality totally.

Happy with a fix for this or suggestion for another one that has this feature.

Richard KortsBusiness Owner / Chief DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:

You just need to add a readonly attribute-

<input type="text" name="datepicker" id="datepicker" readonly="readonly" />
Chris StanyonWebDevCommented:
Hi Richard,

The constrainInput property simply prevents the user typing in characters that aren't permitted. It doesn't mean that it will force the user to type in a valid date. Permitted characters are likely to be [0-9] and a slash, so they could still type in 123/456/789. It's not a valid date but it is using only permitted characters.

As @Rikin has said, if you want to prevent users typing directly into the field, then set it to readonly. FYI - readonly is just a boolean attribute and as such, you don't need to give it a value - just add the attribute:

<input type="text" id="datepickertd" name="datepickertd" readonly>

You said that the code you've provided prevents the functionality totally - that's because you have errors in that code - you have an extra ;) on the third line. It should be:

$(function() {
        constrainInput: true

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
Perfect, that solves the issue.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.