请问一下下面的代码错在哪里,为什么整个js都不能使用。
<scripttype="text/javascript">/*根据元素id获取元素的函数*/function$(elementId){returndocument.ge...
<script type="text/javascript">
/*根据元素id获取元素的函数*/
function $(elementId){
return document.getElementById(elementId);
}
/*验证用户名*/
function checkUser(){
var user = $("user").value;
var userId = $("user_prompt");
userId.innerHTML = "";
var reg = /^[a-zA-Z][a-zA-ZO-9]{3,15}$/;
if(reg.test(user)==false){
userId.innerHTML = "用户名不正确";
return false;
}
return true;
}
/*验证密码*/
function checPwd(){
var pwd = $("repwd").value;
var pwdId = $("pwd").valur;
var repwId = $("repwd_prompy");
repwdId.innerHTML = "";
var reg = /^[a-zA-ZO-9]{4,10}$/;
if(reg.test(pwd)==false){
repwdId.innerHTML = "密码长度在4-10之间";
return false ;
}
return true ;
}
/*验证确认密码*/
function checkRepwd(){
var repwd = $("repwd").value;
var pwd = $("pwd").valur;
var repwdId = $("repwd_prompy");
repwdId.innerHTML = "";
if(pwd!=repwd){
repwdId.innerHTML = "两次输入的密码不一致!";
return false ;
}
return true ;
}
/*验证邮箱*/
function checkEmail(){
var email = $("email").value;
var email_prompt = $("email_prompt");
email_prompt.innerHTML = "";
var reg = /^\w+@\w+\.\w+[(com)|(cn)]$/;
if(reg.test(email)==false){
email_prompt.innerHTML = "Email格式不正确,例如web@sohu.com";
return false;
}
return true;
}
/*验证手机号*/
function checkMobile(){
var mobile = $("mobile").value;
var mobileId = $("mobile_prompt");
var reg = /^1[3|4|5|7|8]\d{9}$/;
if(reg.test(mobile)==false){
mobileId.innerHTML = "手机号码不正确,请重新输入!";
return false;
}
mobileId.innerHTML = "";
return true;
}
/*验证出生日期*/
function checkBirth(){
var birth = $("birth").value;
var birthId = $("birth_prompt");
var reg = /((19\d{2})|(200\d)|(201[0-5]))-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])/;
if(reg.test(birth)==false){
birtId.innerHTML = "生日格式不正确,例如1980-05-12或1988-0504";
return false;
}
birthId.innerHTML = "";
return true;
}
</script>
这是所有代码,求解答哪里错误。 展开
/*根据元素id获取元素的函数*/
function $(elementId){
return document.getElementById(elementId);
}
/*验证用户名*/
function checkUser(){
var user = $("user").value;
var userId = $("user_prompt");
userId.innerHTML = "";
var reg = /^[a-zA-Z][a-zA-ZO-9]{3,15}$/;
if(reg.test(user)==false){
userId.innerHTML = "用户名不正确";
return false;
}
return true;
}
/*验证密码*/
function checPwd(){
var pwd = $("repwd").value;
var pwdId = $("pwd").valur;
var repwId = $("repwd_prompy");
repwdId.innerHTML = "";
var reg = /^[a-zA-ZO-9]{4,10}$/;
if(reg.test(pwd)==false){
repwdId.innerHTML = "密码长度在4-10之间";
return false ;
}
return true ;
}
/*验证确认密码*/
function checkRepwd(){
var repwd = $("repwd").value;
var pwd = $("pwd").valur;
var repwdId = $("repwd_prompy");
repwdId.innerHTML = "";
if(pwd!=repwd){
repwdId.innerHTML = "两次输入的密码不一致!";
return false ;
}
return true ;
}
/*验证邮箱*/
function checkEmail(){
var email = $("email").value;
var email_prompt = $("email_prompt");
email_prompt.innerHTML = "";
var reg = /^\w+@\w+\.\w+[(com)|(cn)]$/;
if(reg.test(email)==false){
email_prompt.innerHTML = "Email格式不正确,例如web@sohu.com";
return false;
}
return true;
}
/*验证手机号*/
function checkMobile(){
var mobile = $("mobile").value;
var mobileId = $("mobile_prompt");
var reg = /^1[3|4|5|7|8]\d{9}$/;
if(reg.test(mobile)==false){
mobileId.innerHTML = "手机号码不正确,请重新输入!";
return false;
}
mobileId.innerHTML = "";
return true;
}
/*验证出生日期*/
function checkBirth(){
var birth = $("birth").value;
var birthId = $("birth_prompt");
var reg = /((19\d{2})|(200\d)|(201[0-5]))-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])/;
if(reg.test(birth)==false){
birtId.innerHTML = "生日格式不正确,例如1980-05-12或1988-0504";
return false;
}
birthId.innerHTML = "";
return true;
}
</script>
这是所有代码,求解答哪里错误。 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询