Results 1 to 3 of 3
Nov 19, 2008, 16:23 #1
- Join Date
- Sep 2005
- 0 Post(s)
- 0 Thread(s)
How can I force user to enter dd/mm/yyyy format when I validate?
Our system has a text field attached calendar widget.
When a user clicks the text field, then calendar pops up,
and it fills the text field with dd/mm/yyyy format as user selects a date on the calendar. something like 30/10/2008
But there is also chances that user might try to enter different date format by deleting the date and entering a date manually, something like 10/30/2008, or Oct 30, 2008 which we don't want.
And there is a submit button, so when user clicks the submit button, I need to give them error message for wrong date format.
How can I validate(force) the text field to have only dd/mm/yyyy date format?
Thanks in advance,
Nov 19, 2008, 17:22 #2
You have a few techniques at your disposal.
1) On the server, use PHP to check the values submitted by the user. Display an error if their values are wrong, and force them to enter it again. This is the most idiot-proof way.
4) Fancy-pants degradable AJAX form validation (example).
In any case, I'd recommend having three separate labeled fields (day, month and year) to prevent mm/dd/yyyy vs. dd/mm/yyyy misunderstandings.
Nov 19, 2008, 18:34 #3
- Join Date
- Oct 2006
- France, deep rural.
- 17 Post(s)
- 1 Thread(s)
I agree with last post.
use checkdate function in case they enter erronious data like 30/2/2008 too.
Inevitably you will find out its far easier to let users pick from a drop-list of values, use checkdate in the first instance on the client to filter out hacks.