I won’t say much nonsense, I will just post the code to you. The specific code is as follows:
<script type="text/javascript"> var refid='dasdasd,dadsad'; var reg =/^([/u0391-/uFFE5/d/w,])*([/u0391-/uFFE5/d/w]+)$/; if(refid != ""){ if(reg.exec(refid)){ alert('verified passed'); }else { alert('verified failed'); } }</script>The code is simple and easy to understand. If you have good suggestions, please give them a suggestion and learn and make progress together!
Supplement: Chinese, numbers, and letters in JS
1.Judge the text as English, numbers and Chinese characters
var reg = /^(/w|[/u4E00-/u9FA5])*$/; if(arr=username.match(reg)) { ti=1; return truth; } else { alert("The username is only allowed to be a mixture of English, numbers and Chinese characters, /n Please check whether there are spaces or other symbols before and after"); ti=0; return false; }2. Use regular expressions to restrict the input content of the text box in the web form:
Use regular expressions to restrict only Chinese:
onkeyup="value=value.replace(/[^/u4E00-/u9FA5]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/u4E00-/u9FA5]/g,''))"Use regular expressions to restrict only full-width characters:
onkeyup="value=value.replace(/[^/uFF00-/uFFFF]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/uFF00-/uFFF]/g,''))"Use regular expressions to limit only numeric input:
onkeyup="value=value.replace(/[^/d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"Use regular expressions to restrict only numeric and English:
onkeyup="value=value.replace(/[/W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^/d]/g,''))"number
<script> function check() { if(!isNaN(document.all.form.str.value)) { alert("number"); } </script>letter
<script> function check() { var str = /[a-zA-Z]/; if(str.test(document.all.form.str.value)) { alert("letter"); } } </script> <form name="form" action="" onsubmit="return check();"> <input type=text name=str> <input type=submit> <form>--------------------------------------------------------------------------------------------------------------------------------
/^[0-9a-zA-Z]+$/