Prevent the letter 'e' and dots from being typed in an input number

前端 未结 2 348
挽巷
挽巷 2020-12-18 00:34

I have a simple input number like this:


When trying to input anything other than a number or the letter \"e\

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-18 01:27

    You can simply use ng-pattern on your input

    Controller

    $scope.onlyDigits= /^\d+$/;
    

    HTML

    
    

    This pattern use \d which is for any numeric value

提交回复
热议问题