$(document).ready(function(){
//创建一个*
$(".a1").each(function(){
var hdw = $("*");
$(this).parent().append(hdw);
});
//end
$("form :input").blur(function(){
$(this).parent().find(".a2").remove();
//判断
if ($(this).is("#username")){
if (this.value=="" || this.value.length < 6){
var hdw1 = $("用户名不得小于6位");
$(this).parent().append(hdw1);
}else{
var hdw1 = $("正确");
$(this).parent().append(hdw1);
}
}
//end
//判断
if ($(this).is("#password")){
if (this.value==""){
var hdw1 = $("密码不得为空");
$(this).parent().append(hdw1);
}else{
var hdw1 = $("正确");
$(this).parent().append(hdw1);
}
}
//end
//判断
if ($(this).is("#passwords")){
if (this.value=="" || this.value!= $("#password").val()){
var hdw1 = $("两次密码不一样");
$(this).parent().append(hdw1);
}else{
var hdw1 = $("正确");
$(this).parent().append(hdw1);
}
}
//end
//判断
if ($(this).is("#email")){
if (this.value=="" || ( this.value!="" && !/.+@.+\.[a-zA-Z]{2,4}$/.test(this.value) )){
var hdw1 = $("邮件的格式不正确");
$(this).parent().append(hdw1);
}else{
var hdw1 = $("正确");
$(this).parent().append(hdw1);
}
}
//end
//判断
if ($(this).is("#tel")){
if (this.value=="" || isNaN($(this).val()) || this.value.length < 11 ){
var hdw1 = $("手机号不得为空,必须是11位数字");
$(this).parent().append(hdw1);
}else{
var hdw1 = $("正确");
$(this).parent().append(hdw1);
}
}
//end
});
//blur end
//提交
$("#send").click(function(){
$("form :input").trigger("blur");
var hdw3 = $(".error").length;
if (hdw3){
return false;
}
alert("注册成功");
});
//end
//重置
$("#res").click(function(){
$(".a2").remove();
});