<script type="text/javascript"> function yanzheng(inputObj){ var regx = /^[\u4e00-\u9fa5]{2,4}$/g; if(!regx.test(inputObj.value)){ alert("Invalid userName"); inputObj.value=""; inputObj.focus(); return false; } } </script> <form> <input name="name" id="name" onblur="yanzheng(this)" placeholder="请输入2-4个汉字名称"/> </form>
时间: 2024-11-13 17:29:33