Numbers with commas in Javascript

后端 未结 4 1344
無奈伤痛
無奈伤痛 2020-12-24 08:02

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 fr

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-24 08:42

    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:

    
    

提交回复
热议问题