How to block +,-,e in input type Number?

后端 未结 13 1846
我在风中等你
我在风中等你 2020-12-29 20:52

When I\'m giving input type number the letter e and special charecters are also displaying in input field. I want to display only digits. How to block them?

13条回答
  •  天命终不由人
    2020-12-29 21:29

    Yo can Block by using some JQuery codes

     $('input[Type="Number"]').keypress(function (e) {
        if ('0123456789'.indexOf(e.key) == -1) {
            e.preventDefault();
        }
    });
    

    This will affect on all Numeric typed Input

提交回复
热议问题