标签:document username ntb span input put char color lse
[\u4e00-\u9fa5]
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>title</title> </head> <body> 请输入您的名字:<input type="text" value="" id="userName" />*<br /> <script> //是中文名字,则绿色,否则红色 document.getElementById("userName").onblur = function () { var reg = /^[\u4e00-\u9fa5]{2,6}$/; if (reg.test(this.value)) { this.style.backgroundColor = "green"; } else { this.style.backgroundColor = "pink"; } }; </script> </body> </html>
标签:document username ntb span input put char color lse
原文地址:https://www.cnblogs.com/jane-panyiyun/p/12192392.html