How to prevent entering comma into field?

hominid4

Member
The form on the below page has several AJAX calculation elements and there is a "Quantity". All works as we need except if a comma is entered in the "Quantity" it doesn't take into account any numbers after the comma. Such as 5 and 5,000 returns the same Total.

http://www.lithoninja.com/requests/comic-print/form/1.html

How would it be possible to disallow entering a comma, or any other character besides a number for that matter, so that 5,000 becomes 5000 during the AJAX calculations?

That element is a field element:
Eval: Yes
Default: return 1;
Auto Complete: Yes
Format: Integer
Number Format: No

Thanks!
 
I was able to remove the comma in the calculations but not sure if I'm heading in the right direction?

In each of my calculation elements I had the below variable which I then use throughout the calculation:
Code:
$quantity = '{f_p_comic___quantity_raw}';

I've changed that to:
Code:
$quantity = str_replace(',', '', '{f_p_comic___quantity_raw}');

I have 6 different calc elements in this form and each have the variable above. To fix my "comma" problem, is it correct that I should update my code in each calc element, instead of modifying the one Quantity field element?

Thanks!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top