Copy link to clipboard
Copied
Hi everyone,
How can I filter out commas from a number entered by a user into a input text field? I am trying to do calculations with those numbers entered, but if the user enters a comma, i get "NaN" (not a number) as the result of what the user entered.
I could restrict the user from entering commas into the fields (I am already restriciting entering letters and periods), but it would be nice if the user can still use commas.
the code I have so far is:
q4input = q4_mc.q4_ans.text;
q4_preCalc = (Number(q4input)*1000);
trace(q4_preCalc);
thank you for your help in advance.
Rafael.
Try:
q4input = q4_mc.q4_ans.text.replace(",", "");
Copy link to clipboard
Copied
Try:
q4input = q4_mc.q4_ans.text.replace(",", "");
Copy link to clipboard
Copied
Andrei1,
Thank you, that worked perfectly.
Rafael.
Copy link to clipboard
Copied
You are welcome.
Copy link to clipboard
Copied
If commas give error , then this should work I think:
q4input = q4_mc.q4_ans.text.replace(",", ".");
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more