Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
Add another page asking the user to CONFIRM the amount that you think you got. On Thu, August 2, 2007 3:07 pm, Dan Shirah wrote: > Greetins all, > > In my form I have an area where the user enters in the payment amount: > > name="payment_amount"> > > This is all fine and dandy and works as generically as it can. BUT, > the > problem is that I need to make sure the user didn't fat finger any of > the > numbers. For instance, in my generic text field the user types 600 in > the > payment amount and clicks submit. > > This works and the user is charged $600. But, come to find out the > user > meant to enter 6.00 not 600. Can I add a check using PHP to force the > user > to put in the dollar AND cents? This way if a number such as 600 is > entered > and the user hits save, the check will notice there isn't a .00 on the > end > and prompt the user for more information. > > Could I incorporate something like: > > if ($payment_amount != number_format($payment_amount, 2)) { > error here > } > > Or, do you think I would be better off using two text areas? One for > the > dollar value and one for the cents? > > Or, do you think I would be better off trying to find some kind of > javascript function that would check the value upon submit? > > Any help is appreciated. > > Dan > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
Thanks for all of the suggestions. While I agree that I shouldn't have to write a check for stupid users, the supervisor of the employees that will be using this application is VERY insistent! I am going to try the Javascript route...too bad the javascript forums are not as helpful as all of you! On 8/3/07, David Giragosian <[EMAIL PROTECTED]> wrote: > > On 8/3/07, tedd <[EMAIL PROTECTED]> wrote: > > > > At 12:57 AM +0200 8/3/07, M. Sokolewicz wrote: > > >Now, as mentioned before: You have to decide for yourself if your > > >application is the correct place to check for the stupidity of your > > >users. > > > > Check for the ignorance of your users -- there's a difference. > > > > Cheers, > > > > tedd > > -- > > > You need to check for both stupidity and ignorance; they are different and > not mutually exclusive. But please, let's not turn this into another > "pirated books" thread. That's the only discussion from this list that I've > ever filtered out. > > David > > >
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
On 8/3/07, tedd <[EMAIL PROTECTED]> wrote: > > At 12:57 AM +0200 8/3/07, M. Sokolewicz wrote: > >Now, as mentioned before: You have to decide for yourself if your > >application is the correct place to check for the stupidity of your > >users. > > Check for the ignorance of your users -- there's a difference. > > Cheers, > > tedd > -- You need to check for both stupidity and ignorance; they are different and not mutually exclusive. But please, let's not turn this into another "pirated books" thread. That's the only discussion from this list that I've ever filtered out. David
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
At 12:57 AM +0200 8/3/07, M. Sokolewicz wrote: Now, as mentioned before: You have to decide for yourself if your application is the correct place to check for the stupidity of your users. Check for the ignorance of your users -- there's a difference. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
Tijnema wrote: On 8/2/07, Brad Bonkoski <[EMAIL PROTECTED]> wrote: Dan Shirah wrote: Greetins all, In my form I have an area where the user enters in the payment amount: This is all fine and dandy and works as generically as it can. BUT, the problem is that I need to make sure the user didn't fat finger any of the numbers. For instance, in my generic text field the user types 600 in the payment amount and clicks submit. This works and the user is charged $600. But, come to find out the user meant to enter 6.00 not 600. Can I add a check using PHP to force the user to put in the dollar AND cents? This way if a number such as 600 is entered and the user hits save, the check will notice there isn't a .00 on the end and prompt the user for more information. Could I incorporate something like: if ($payment_amount != number_format($payment_amount, 2)) { error here } Or, do you think I would be better off using two text areas? One for the dollar value and one for the cents? Or, do you think I would be better off trying to find some kind of javascript function that would check the value upon submit? Any help is appreciated. Dan If you want it squarely on the client side, then use javascript. There are easy functions to split a text string (like php's explode). Then you can split on the '.' and then do some logical stuff like the cents is between 00 and 99, and anything else you think necessary. If there are no cents, then you can issue a confirmation box. So, my vote is to handle it within javascript, as it should not be too difficult. -B What about the european format? Like this: $1.234.567,89 Tijnema Most people from the US don't understand that most of the world uses different ways of denoting currency, dates, etc, so this is a very valid point! Now, as mentioned before: You have to decide for yourself if your application is the correct place to check for the stupidity of your users. If and only IF you decide you want to second-guess your users (I wouldn't usually, but it's up to you really), then you have the choice of where and when to do it. Assuming you want to do it around the submitting of the form, you have 3 choices: 1. client-side via a client-side language like J(ava)Script(/ECMAScript), VBScript, etc. 2. server-side via AJAX 3. server-side in PHP All of these have their advantages and disadvantages. Advantages: 1. (client-side) Easy to make, if the code decides the user might have made a mistake, the user can just change it and try again. 2. (AJAX) very complex checks can be performed easily against a lot of data stored already. Though this is usually not required. 3. (server-side) same as with AJAX. Disadvantages: 1. You need to remember that your form should work with J(ava)Script (or any such language) turned OFF. 2. You need to do quite a lot of (usually useless) work, coding a complex and probably over-the-top check for something very simple. 3. If the user might have made a mistake, you need to make sure that the user does not have to fill _all_ fields again, and that state is preserved. Personally, IF I would've chosen to check what the user did on such a thing, I'd do it via JavaScript, and later would perform sanity-checks on it via PHP (ie. is the number > 0.00 and less than some insane max_number (eg. < 500)). - Tul P.S. Always remember non-US users, there's few things more annoying than being forced to use a format you are not familiair with using (ie. if I am forced insert a date formatted like month/day/year, I usually don't bother and leave the site). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
On 8/2/07, Brad Bonkoski <[EMAIL PROTECTED]> wrote: > Dan Shirah wrote: > > Greetins all, > > > > In my form I have an area where the user enters in the payment amount: > > > > > > > > This is all fine and dandy and works as generically as it can. BUT, the > > problem is that I need to make sure the user didn't fat finger any of the > > numbers. For instance, in my generic text field the user types 600 in the > > payment amount and clicks submit. > > > > This works and the user is charged $600. But, come to find out the user > > meant to enter 6.00 not 600. Can I add a check using PHP to force the user > > to put in the dollar AND cents? This way if a number such as 600 is entered > > and the user hits save, the check will notice there isn't a .00 on the end > > and prompt the user for more information. > > > > Could I incorporate something like: > > > > if ($payment_amount != number_format($payment_amount, 2)) { > > error here > > } > > > > Or, do you think I would be better off using two text areas? One for the > > dollar value and one for the cents? > > > > Or, do you think I would be better off trying to find some kind of > > javascript function that would check the value upon submit? > > > > Any help is appreciated. > > > > Dan > > > > > If you want it squarely on the client side, then use javascript. There > are easy functions to split a text string (like php's explode). > Then you can split on the '.' and then do some logical stuff like the > cents is between 00 and 99, and anything else you think necessary. > If there are no cents, then you can issue a confirmation box. So, my > vote is to handle it within javascript, as it should not be too difficult. > -B What about the european format? Like this: $1.234.567,89 Tijnema -- Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
On 8/2/07, Brad Bonkoski <[EMAIL PROTECTED]> wrote: > > Dan Shirah wrote: > > Greetins all, > > > > In my form I have an area where the user enters in the payment amount: > > > > name="payment_amount"> > > > > This is all fine and dandy and works as generically as it can. BUT, the > > problem is that I need to make sure the user didn't fat finger any of > the > > numbers. For instance, in my generic text field the user types 600 in > the > > payment amount and clicks submit. > > > > This works and the user is charged $600. But, come to find out the user > > meant to enter 6.00 not 600. Can I add a check using PHP to force the > user > > to put in the dollar AND cents? This way if a number such as 600 is > entered > > and the user hits save, the check will notice there isn't a .00 on the > end > > and prompt the user for more information. > > > > Could I incorporate something like: > > > > if ($payment_amount != number_format($payment_amount, 2)) { > > error here > > } > > > > Or, do you think I would be better off using two text areas? One for > the > > dollar value and one for the cents? > > > > Or, do you think I would be better off trying to find some kind of > > javascript function that would check the value upon submit? > > > > Any help is appreciated. > > > > Dan > > > > > If you want it squarely on the client side, then use javascript. There > are easy functions to split a text string (like php's explode). > Then you can split on the '.' and then do some logical stuff like the > cents is between 00 and 99, and anything else you think necessary. > If there are no cents, then you can issue a confirmation box. So, my > vote is to handle it within javascript, as it should not be too difficult. > -B No ecommerce site I've ever used allowed me to manually enter in what I owed. I clicked, checked, or somehow selected a product to buy and everything was calculated behind the scenes and displayed. If you must allow this behavior, I'd opt for perhaps somewhat unappealing select boxes for all numerical input, one per field. As Ron White jokes, "You can't fix stupid", and if you don't expect your users to be stupid, they will surprise you every time. Just MHO, David
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
On 8/2/07, Dan Shirah <[EMAIL PROTECTED]> wrote: > Greetins all, > > In my form I have an area where the user enters in the payment amount: > > > > This is all fine and dandy and works as generically as it can. BUT, the > problem is that I need to make sure the user didn't fat finger any of the > numbers. For instance, in my generic text field the user types 600 in the > payment amount and clicks submit. > > This works and the user is charged $600. But, come to find out the user > meant to enter 6.00 not 600. Can I add a check using PHP to force the user > to put in the dollar AND cents? This way if a number such as 600 is entered > and the user hits save, the check will notice there isn't a .00 on the end > and prompt the user for more information. > > Could I incorporate something like: > > if ($payment_amount != number_format($payment_amount, 2)) { > error here > } > > Or, do you think I would be better off using two text areas? One for the > dollar value and one for the cents? > > Or, do you think I would be better off trying to find some kind of > javascript function that would check the value upon submit? > > Any help is appreciated. > > Dan > But what if they type in 600.00? I understand your logic, but you can't really save users from themselves. You can put a notice on there that says check your price field, but I'm sure the same person who ignored what they typed in the first time will ignore any hurdles you stick in front of them until the form submits. I'm not sure exactly what your form is for, but perhaps you could do a select dropdown with a few standard rates and then an input for other amount. That might help if this is a common issue. Good luck. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
On 8/2/07, Dan Shirah <[EMAIL PROTECTED]> wrote: > Greetins all, > > In my form I have an area where the user enters in the payment amount: > > > > This is all fine and dandy and works as generically as it can. BUT, the > problem is that I need to make sure the user didn't fat finger any of the > numbers. For instance, in my generic text field the user types 600 in the > payment amount and clicks submit. > > This works and the user is charged $600. But, come to find out the user > meant to enter 6.00 not 600. Can I add a check using PHP to force the user > to put in the dollar AND cents? This way if a number such as 600 is entered > and the user hits save, the check will notice there isn't a .00 on the end > and prompt the user for more information. > > Could I incorporate something like: > > if ($payment_amount != number_format($payment_amount, 2)) { > error here > } > > Or, do you think I would be better off using two text areas? One for the > dollar value and one for the cents? > > Or, do you think I would be better off trying to find some kind of > javascript function that would check the value upon submit? > > Any help is appreciated. > > Dan > "woot woot" That's all really a matter of preference, Dan. You could even just check to ensure that there's a period in there, and if not, emit an error message that the user is required to enter the full amount in dollars and cents. ".$err[$i]."\n"; } ?> -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Numbers, Numbers everywhere! Need some Dollar help.
Dan Shirah wrote: Greetins all, In my form I have an area where the user enters in the payment amount: This is all fine and dandy and works as generically as it can. BUT, the problem is that I need to make sure the user didn't fat finger any of the numbers. For instance, in my generic text field the user types 600 in the payment amount and clicks submit. This works and the user is charged $600. But, come to find out the user meant to enter 6.00 not 600. Can I add a check using PHP to force the user to put in the dollar AND cents? This way if a number such as 600 is entered and the user hits save, the check will notice there isn't a .00 on the end and prompt the user for more information. Could I incorporate something like: if ($payment_amount != number_format($payment_amount, 2)) { error here } Or, do you think I would be better off using two text areas? One for the dollar value and one for the cents? Or, do you think I would be better off trying to find some kind of javascript function that would check the value upon submit? Any help is appreciated. Dan If you want it squarely on the client side, then use javascript. There are easy functions to split a text string (like php's explode). Then you can split on the '.' and then do some logical stuff like the cents is between 00 and 99, and anything else you think necessary. If there are no cents, then you can issue a confirmation box. So, my vote is to handle it within javascript, as it should not be too difficult. -B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Numbers, Numbers everywhere! Need some Dollar help.
Greetins all, In my form I have an area where the user enters in the payment amount: This is all fine and dandy and works as generically as it can. BUT, the problem is that I need to make sure the user didn't fat finger any of the numbers. For instance, in my generic text field the user types 600 in the payment amount and clicks submit. This works and the user is charged $600. But, come to find out the user meant to enter 6.00 not 600. Can I add a check using PHP to force the user to put in the dollar AND cents? This way if a number such as 600 is entered and the user hits save, the check will notice there isn't a .00 on the end and prompt the user for more information. Could I incorporate something like: if ($payment_amount != number_format($payment_amount, 2)) { error here } Or, do you think I would be better off using two text areas? One for the dollar value and one for the cents? Or, do you think I would be better off trying to find some kind of javascript function that would check the value upon submit? Any help is appreciated. Dan