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

后端 未结 6 1319
甜味超标
甜味超标 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:53

    check out regular expressions and patterns.

    function f1() 
    {  
       var x=document.f.name.value;  
       return /^[A-z ]+$/.test(x);
    }
    

提交回复
热议问题