jquery - validate characters on keypress?

前端 未结 7 1386
既然无缘
既然无缘 2020-12-05 10:25

I have a form text field that I want to allow only numbers and letters in. (i.e., no #$!, etc...) Is there a way to throw up an error and prevent the keypress from actuall

7条回答
  •  无人及你
    2020-12-05 10:57

    $('#yourfield').keydown(function(e) {
        // Check e.keyCode and return false if you want to block the entered character.
    });
    

提交回复
热议问题