jkkenzie Posted April 22, 2008 Share Posted April 22, 2008 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 Quote Link to comment Share on other sites More sharing options...
947740 Posted April 22, 2008 Share Posted April 22, 2008 For this, you need javascript (if you want it done client-side). You could use php, but it is easier on load time if you do it client-side. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 22, 2008 Share Posted April 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
jkkenzie Posted April 23, 2008 Author Share Posted April 23, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.