Commas messing with number input in Javascript

前端 未结 4 1991
半阙折子戏
半阙折子戏 2020-11-30 11:07

I have a page with some elements that are controlled by the user. One of these is a text input field, where the user is supposed to input a number. Everything works well if

4条回答
  •  一生所求
    2020-11-30 11:19

    maybe

     parseint(ny9000withCommas.replace(/\,/g,""))
    

    lets talk about the restriction :

    you can/should allow the user to enter both 9000 & 9,000

    you can check validy via REGEX.

    in the server side - you should eleminate the commas and treat it as integer.

提交回复
热议问题