JS判定英文半角符号
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JS判定英文半角符号</title> </head> <body> <script> var reg = /[\x21-\x2f\x3a-\x40\x5b-\x60\x7B-\x7F]/; function isValid(str) { return reg.test(str); } str = "1234ab"; document.write(isValid(str)+': '+str); document.write("<br>"); str2 = "$32343#"; document.write(isValid(str2)+': '+str); document.write("<br>"); </script> </body> </html>