parseInt always returns NaN?

后端 未结 4 622
太阳男子
太阳男子 2020-12-06 12:48

long story short, i was trying to validate a phone field. ive added the isNaN and parseInt for checking the \" \" in the field but tha

4条回答
  •  臣服心动
    2020-12-06 13:16

    parseInt is a bit odd at times:

    > parseInt("123-456-789")
    123
    

    Fortunately you can probably solve your case with:

    > Number("123-456-789")
    NaN
    

提交回复
热议问题