$(function(){
	
	$("#bmform").submit(function(){
		
		if($("#name").val()==""){
			art.dialog({content:'姓名必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#card").val()==""){
			art.dialog({content:'身份证必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#sid1").val()=="第一志愿"){
			art.dialog({content:'第一志愿必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#sname").val()==""){
			art.dialog({content:'收信人必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#tel").val()==""){
			art.dialog({content:'联系方式必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#address").val()==""){
			art.dialog({content:'家庭住址必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#code").val()==""){
			art.dialog({content:'邮编必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#putup").val()==""){
			art.dialog({content:'住宿标准必须！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#card").val().match(/^\d{15}|\d{18}$/)==null){
			art.dialog({content:'身份证格式错误！', style:'error', width:'30em', lock:true});
			return false;
		}
		
		var patter=/^\d{3}\-\d{8}|\d{4}\-\d{7}$/;
		if($("#tel").val().match(/^\d{3}\-\d{8}|\d{4}\-\d{7}|\d{11}$/)==null){
			art.dialog({content:'电话格式错误！', style:'error', width:'30em', lock:true});
			return false;
		}
		if($("#code").val().match(/^\d{6}$/)==null){
			art.dialog({content:'邮编格式错误！', style:'error', width:'30em', lock:true});
			return false;
		}
		
	});
	
	 //检查身份证是否唯一
	$("#card").blur(function(){

		$.ajax({
			type:'POST',
			url:URL+'/chkCard/',
			data:'card='+$(this).val(),
			success:function(msg){
				
				if(msg==1){
					art.dialog({content:'请核实你的身份证号，如有疑问，请致电0773-3336666！', style:'error', width:'30em', lock:true});
				}
			}
		})
		
	});
})
