JS 判断字符串是否全部为字母
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <p> 使用正则表达式的方式来判断。 </p> <script> val = "123456" var isletter = /^[a-zA-Z]+$/.test(val); document.write(isletter); document.write("<br>"); val2 = "asaaa" var isletter2 = /^[a-zA-Z]+$/.test(val2); document.write(isletter2); </script> </body> </html>