Javascript - validation, numbers only

前端 未结 14 1688
感动是毒
感动是毒 2020-12-08 09:52

I\'m trying to get my login form to only validate if only numbers were inputted. I can it to work if the input is only digits, but when i type any characters after a number,

14条回答
  •  自闭症患者
    2020-12-08 10:42

    function ValidateNumberOnly()
    {
    if ((event.keyCode < 48 || event.keyCode > 57)) 
    {
       event.returnValue = false;
    }
    }
    

    this function will allow only numbers in the textfield.

提交回复
热议问题