Jump to content

Best way to take date input from user?


AlphaWolf

Recommended Posts

Hi,

I'm using the form data type 'date', and trying to verify it. It seems a little too complicated to check that it's in the correct format (with "/" between day/month/year), unless I use regular expression, which I don't know much about and seems feels like there's an alternate solution or it's not necessary. Currently, the script accepts DD*MM*YYYY, where * is any character, since it just strips the 3rd and 6th character and checks the day/month/year using checkdate().

I'm not even sure if this is a problem. I am giving the user a "verify" page, where I could put it in the correct format (DD/MM/YYYY), but is that enough?

Feel like I'm missing something here, so any feedback would be great :)

Link to comment
Share on other sites

Just use 3 input boxes

 

 

<form method="post">
Date (d/m/Y): <input size="2" maxlength="2" title="Day of month" name="day" > <input size="2" maxlength="2" title="Month of year" name="month" > <input size="4" maxlength="4" title="Year" name="Year" >
</form>

 

I also like to use jQuery mouse wheel to scroll through days/months/years and a pop-up calendar, I wrote an extension to do both but it's on my work computer :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.