js正則表達式驗證中文和英文及數字


<script type= "text/javascript" >
function check(v){
  var regex = new RegExp( "^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_]){1,20}$" );//不包含“-”
 //var  regex =  new  RegExp( "^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_-]){1,20}$" );//包含“-”
  var res = regex.test(v);
  if (res== true ){
   alert( "包含中英文字母或下划線" );
   return true ;
  } else {
   alert( "不包含中英文字母或下划線" );
   return false ;
  }
}
check( '博客園90_qwe' );


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM