Tip: you can modify some code before running
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Js Chinese user name detection function</title><script language="javascript">Function $ (obj) {return document. getElementById (obj)} function check () {username = $ ('Username '). value; if (username. length = 0 | username = 'Enter your name' | username. replace (/[]/g, "") = '') {alert ('Enter your name'); return false ;} var reg =/^ [u4e00-u9fa5] + $/; var reg1 =/^ [A-Za-z] + $/; if (reg. test (username) {if (username. length> 7) {alert ('name of a Chinese character smaller than 7'); return false;} else {alert (username ); return false} else {alert ('Enter a Chinese name! '); Return false ;}}</script></head><body><form id="form1" name="form1" method="post" action=""> <label for="textfield"></label> <input type="text" name="userName" id="userName" /> <input type="submit" name="button" id="button" onclick="return check();"value="检测" /></form></body></html>
Tip: you can modify some code before running