web前端之javascript练习题

javascript 练习题,正则表达式
表单验证
简略布局


Q Q

手机

邮箱

座机

姓名

js代码:
checkInput(my$("qq"),/^d{5,11}$/); //qq的
checkInput(my$("phone"),/^d{11}$/); //手机
checkInput(my$("e-mail"),/^[0-9a-zA-Z_.-]+[@][0-9a-zA-Z_.-]+([.][a-zA-Z]+){1,2}$/); //邮箱
checkInput(my$("telephone"),/^d{3,4}[-]d{7,8}$/); //座机号码
checkInput(my$("fullName"),/^[u4e00-u9fa5]{2,6}$/); //中文姓名//经过正则表达式验证当时的文本框是否匹配并闪现作用
function checkInput(input,reg) {

//文本框注册失掉焦点的作业
input.onblur=function () {
if(reg.test(this.value)){
this.nextElementSibling.innerText="正确了";
this.nextElementSibling.style.color="green";
}else{
this.nextElementSibling.innerText="让你得瑟,错了吧";
this.nextElementSibling.style.color="red";
}
};

}