How to validate a letter and whitespace only input via JavaScript regular expression

后端 未结 6 1348
甜味超标
甜味超标 2021-01-04 10:55

I have an input type=\"text\" for names in my HTML code. I need to make sure that it is a string with letters from \'a\' to \'z\' and \'A\' to \'Z\' only, along

6条回答
  •  耶瑟儿~
    2021-01-04 11:45

    If you are building something for modern browsers, there is something very pleasurable in HTML5:

    
    

    Reference: HTML5 forms input types

    Update 2017/01/17:

    Old browsers are quite weak on the market shares nowadays. This is a good practice to use HTML5 features instead of compatibility scripts.

提交回复
热议问题