看注释
前端手机号校验
function checkUserName(){
var str = $("#name").val();
var number=str.toString().replace(/[^0-9]/ig,"");
if(number.length<11){
return false;
}
if (cur.match(/^[1]([3-9])[0-9]{9}$/)) {
return true
}else {
return false
}
}
后端校验手机号
private def isExistPhone(name:String): Boolean ={
val pattern = new Regex("[1]([3-9])[0-9]{9}")
val number=(pattern findAllIn name).mkString("")
val p = Pattern.compile("^[1]([3-9])[0-9]{9}$")
val m = p.matcher(number)
if(m.matches()){
return true
}
return false
}