Jump to content

Input Masks


jkkenzie

Recommended Posts

When a user is keying in date on a page input box for date, how do you people out there make sure that date is entered properly using an input mask or javascript or what?

 

How about the input for currency? i.e a user wants to input a price of an item, there has to be a comma after every three characters from the left and a $ sign before the integers, how do you do this ?

 

What are the codes?

 

Regards,

Joseph

Link to comment
Share on other sites

You know how to use PHP, right?  Then it's quite simple.  For the number one, just use number_format(), and for the date one, just validate it by making sure the month is less than 12 but > 1, and date is >1 but <31 (depending on month), and make sure the year is between 1970 and 2008.  Or however high you want it to go.

Link to comment
Share on other sites

Indeed. Forcing the user to put their own date separators in isn't great in my opinion. You should use three different text boxes and place the slashes/dashes yourself.

 

As for validation, most people would use javascript and PHP. Javascript is user friendly, since a user will be notified of mistakes without having to submit the page and wait for a reload. However, you need PHP to repeat the checks server side, since a user may have javascript turned off.

Link to comment
Share on other sites

Thanks guys, i think i would go for three input boxes separated by / and labeled Day,Month,Year. Then when saving i would  save them also separately along the record. when loading for display i would join them. That is easy, thanks very much.

 

 

Regards,

JKM

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.