<html >
<head>
<title> js验证手机号 </title>
<script type="text/javascript">
String.prototype.Trim = function() {
var m = this.match(/^/s*(/S+(/s+/S+)*)/s*$/);
return (m == null) ? "" : m[1];
}
String.prototype.isMobile = function() {
return (/^(?:13/d|15[89])-?/d{5}(/d{3}|/*{3})$/.test(this.Trim()));
}
function chkForm(form) {
if (form.tel.value.isMobile()) {
form.tel.value=form.value.Trim();
return true;
} else {
alert("请输入正确的手机号码!");
}
return false;
}
</script>
</head>
<body>
<form name="form1" method="post" action="" οnsubmit="return chkForm(this);">
<input type="text" name="tel" size="30" /><input type="submit" value="提交" />
</form>
</body>
</html>