Allow text box only for letters using jQuery?

后端 未结 11 1607
情书的邮戳
情书的邮戳 2020-11-29 04:42

I want to make a text box allow only letters (a-z) using jQuery. Any examples?

11条回答
  •  情书的邮戳
    2020-11-29 05:17

    Supports backspace:

    new RegExp("^[a-zA-Z \b]*$");
    

    This option will not check mobile. So you can use a jQuery Mask Plugin and use following code:

    jQuery('.alpha-field, input[name=fname]').mask('Z',{translation:  {'Z': {pattern: /[a-zA-Z ]/, recursive: true}}});
    

提交回复
热议问题