<script>
var name,phone,email,address;
function getVal() {
name=$(".input1").val();
phone=$(".input2").val();
email=$(".input3").val();
address=$(".input4").val();
}
function checkName() {
getVal();
if(!(/^([\u4e00-\u9fa5]){2,4}$/.test(name))){
$("#input1").html('姓名必须为汉字');
return false;
}else{
$("#input1").html('');
}
}
function checkPhone() {
getVal();
if(!(/^1[34578]\d{9}$/.test(phone))){
$("#input2").html('手机号码不正确');
return false;
}else{
$("#input2").html('');
}
}
function checkEmail() {
getVal();
if(!(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(email))){
$("#input3").html('邮箱不正确');
return false;
}else{
$("#input3").html('');
}
}
function checkAddress() {
getVal();
if(address==""){
$("#input4").html('地址不能为空');
return false;
}else{
$("#input4").html('');
}
}
$(".submit").click(function () {
if(checkName()==false||checkPhone()==false||checkEmail()==false||checkAddress()==false){
}else {
getVal();
var formhash=$("input[name='formhash']").val();
var form_submit=$("input[name='form_submit']").val();
$.ajax({
url:'index.php?act=index&op=mobile_agent_join_in',
type:'POST',
data:{
"form_submit":form_submit,
"user_name":name,
"mobile":phone,
"email":email,
"company":address,
"formhash":formhash
},
success:function(data){
var resData=JSON.parse(data);
if (resData.state == 1){
alert(resData.msg);
}else {
alert(resData.msg);
}
}
});
}
});
</script>