Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  159] [ 2]  / answers: 1 / hits: 51781  / 15 Years ago, thu, may 7, 2009, 12:00:00

I have a javascript function that accepts a number and performs a mathematical operation on the number. However, the number I'm passing in could have a comma in it, and from my limited experience with Javascript I am having problems working with that value. It doesn't seem to treat that as a numeric type.



What's the easiest way to take a parameter with a value of 1,000 and convert it to a numeric 1000?


More From » regex

 Answers
11

You can set up your textbox to have an onblur() function so when the user attempts to leave the textbox, you then remove the commas from the value by using the javascript replace function



example:



  function checkNumeric(objName)
{
var lstLetters = objName;

var lstReplace = lstLetters.replace(/,/g,'');
}


With input tag here:



<input type=text onblur=checkNumeric(this); name=nocomma size=10 maxlength=10/>

[#99583] Friday, May 1, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryder

Total Points: 473
Total Questions: 110
Total Answers: 91

Location: Northern Ireland
Member since Mon, Nov 14, 2022
2 Years ago
ryder questions
Tue, Nov 30, 21, 00:00, 3 Years ago
Fri, Jul 23, 21, 00:00, 3 Years ago
Tue, Jun 15, 21, 00:00, 3 Years ago
Thu, May 20, 21, 00:00, 3 Years ago
;