Jason C. Levine
asked on
Disable keyboard entry on date field. Force use of calendar popup
Hi folks,
Is it possible to disable people from attempting to type dates into a HTML field and instead just make them use the javascript calendar popup?
Is it possible to disable people from attempting to type dates into a HTML field and instead just make them use the javascript calendar popup?
How about just removing the "HTML field" where you don't want them to enter anything, and just leave the calendar?
You could try some of the following:
<!-- This way, whenever the field gains focus, it automatically loses focus -->
<input type="text" id="date" onfocus="this.blur();" />
<!-- This way, the user cannot type anything -->
<input type="text" id="date" onkeypress="return false;" />
readonly
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So declaring a field as readonly will still allow the javascript date-picker to write the value chosen into the field?
"So declaring a field as readonly will still allow the javascript date-picker to write the value chosen into the field?"
Yes... as javascript is probably using element.value = ''; and "readonly" blocks user input only
Yes... as javascript is probably using element.value = ''; and "readonly" blocks user input only
ASKER
Alrighty. Will test and report back tomorrow night.
Thanks to all who have submitted to this point. I really appreciate your taking the time to assist me.
Thanks to all who have submitted to this point. I really appreciate your taking the time to assist me.
ASKER
Setting the field to readdonly worked. I was under the impression that the field would not accept any data if I used that attribute. Happy to be wrong.
ASKER
Nice and easy. My favorite kind of solution.