







            


//获取性别值，修改提交时使用。
function getQueryForSex(){
	var s1 = jQuery("#sexMan").attr("checked");
	var s2 = jQuery("#sexWoman").attr("checked");
	jQuery("#UserSex").val((s1?1:(s2?2:0)));
}

function CheckDay(yid,mid,did)
{
	var y = jQuery(yid);
	var m = jQuery(mid);
	var d = jQuery(did);
	if( y.length<1 || m.length<1 || d.length<1) return false;
	var yv = y.val();
	var mv = m.val();
	var dv = d.val();
	if(mv==2){
		if(yv%4==0){if(dv>29) d.val(29);}
		else {if(dv>28)d.val(28);}
	}
	else if(mv==4 || mv==6 || mv==9 || mv==11 ){if(dv>30)d.val(30);}
	else {}
	
	//1,3,5,7,8,10,12

}
		//手机激活:发验证码
		function UserMobile_Activation()
		{
			if(confirm("发送手机验证码时将会自动保存您的新的手机号码.\r\n发送完激活码后，手机号文字域将锁定，以保证您输入的手机号与当前进行手机验证的手机号为同一用户。\r\n如果您不打算修改已存的手机号码，请选择取消。")==false)
			{
				return false;
			}
			
			//var _PhoneNo = '<%=DataInfo.UserMobile%>';
			var _PhoneNoInputValue = jQuery("#UserMobile").val();
			//if(_PhoneNo==_PhoneNoInputValue)
			{
				//var queryString = {"PhoneNo":'<%=DataInfo.UserMobile%>'};
				var queryString = {"PhoneNo":_PhoneNoInputValue};
				AjaxSubmit(
							"GET","/index.aspx?s=/UserInfo/honeCheckCodeSend/&IsAdd=6&t="+ new Date().getTime(),queryString,
							function(msg){
							 	//if(msg=="发送成功") 
								//if(msg=="1")
								if(msg.length>0)
								{
									Alert("激活码已发送到您的手机上,请查收.\r\n");
									jQuery("#UserMobile").attr("readonly","readonly");//禁止手机号修改
								}
								else alert("手机短信发送失败,可能的原因:"+ msg );
							},
							function(msg){if(msg!=null && msg.responseText!=null)alert(msg.responseText)}
						);
			}
			//else{alert("请先保存手机号，然后再进行手机号验证。");}
		}
		

//手机激活
		function UserMobile_ActivationCheck()
		{
		var _PhoneNoInputValue = jQuery("#UserMobile").val();
			var queryString ={"PhoneNo":_PhoneNoInputValue,"Code":jQuery("#UserMobile_Code").val()};
			AjaxSubmit(
						"GET","/index.aspx?s=/UserInfo/PhoneCheckCodeCheck/&IsAdd=5&t="+ new Date().getTime(),queryString,
						function(msg){
						 	if(msg=="1") {alert("恭喜,激活成功.");}
							else alert("手机短信激活失败,返回值:"+ msg +",请提交客服中心.");							
						},
						function(msg){if(msg!=null && msg.responseText!=null)alert(msg.responseText)}
					);
		}	


		
		
		
		
		
		
        function checkAll() {
            if (checkUserName($("#UserRealName")) == false) {
            	alert("请输入您的昵称.");
                $("#UserRealName").focus();
                return false;
            }
            /*if (checkCard($("#number"), true) == false) {return false;}*/
            if (checkMobile($("#UserMobile"), true) == false) {
            	alert("请检查您的手机是否有效或为空(手机号11位)?");
                $("#UserMobile").focus();
                return false;
            }
            if (checkEmailInput($("#UserEmail"), true) == false) {
            	alert("请检查您的邮箱地址是否有效或为空?");
                $("#UserEmail").focus();
                return false;
            }
            
            //住址和备注字数限制
            $("#UserRemark").blur(function () {
                checkEmailInput($(this), true);
            });
            
			if($("#UserAddress").val().length>=100){
			
				alert("住址字数限100汉字以内(目前的输入字数:"+ $("#UserAddress").val().length +"字).");return false;
			} 
			
			if($("#UserRemark").val().length>=100){
				alert("备注字数限200汉字以内(目前的输入字数:"+ $("#UserRemark").val().length +"字).");return false;
			} 
            
            return true;
        }		
		
		
function UpdateSubmit()
{
	getQueryForSex();
	
            	//if(checkAll()==true)
				var x = checkform();
				
				if( x)
            	{
					var queryString = $('#frmUpdateInfo').serialize();            	
 					jQuery.ajax({
						"type":"POST",
						"url":"/index.aspx?s=/UserInfo/UserInfoUpdate/&IsAdd=2&t="+ new Date().getTime(),
						"data":queryString,
						"cache":false,
						"dataType":"html",
						"success":function(msg)
						{
						 	if(msg=="1") Alert('会员信息已修改!',1,function(){Common.Refresh();}); //{Alert("会员信息已修改."); window.location.replace("/UserInfo/User.aspx") ;}
							else AlertErr("会员信息修改失败,可能的原因:\r\n 1.登陆超时;\r\n 2.系统故障.\r\n 3.其他.");
							//alert(msg);
							
						},
						"error":function(msg){if(msg!=null && msg.responseText!=null)AlertErr(msg.responseText)}
					});
            	
            	}

}		
		
		

jQuery(function(){
	//日期有效性检查，保证没有不存在的日期被选中。
	jQuery("#UserBirthdayYear").change(function(){CheckDay("#UserBirthdayYear","#UserBirthdayMonth","#UserBirthdayDay");});
	jQuery("#UserBirthdayMonth").change(function(){CheckDay("#UserBirthdayYear","#UserBirthdayMonth","#UserBirthdayDay");});
	jQuery("#UserBirthdayDay").change(function(){CheckDay("#UserBirthdayYear","#UserBirthdayMonth","#UserBirthdayDay");});
	CheckDay("#UserBirthdayYear","#UserBirthdayMonth","#UserBirthdayDay");
	
	
/*
            $("#UserRealName").blur(function () {
          //      checkUserName($(this));
            });
            $("#UserMobile").blur(function () {
            //    checkMobile($(this), true);
            });
            $("#UserEmail").blur(function () {
             //   checkEmailInput($(this), true);
            });	
*/			
	jQuery("#imgBtnSubmit").click(function(){UpdateSubmit();});		
})


//初始化验证配置
jQuery(function($){//select
    jQuery("input,textarea").addClass("warning-normal");
});



   
        function checkform()
        {
            var ok = jQuery.checkForm({
                ctrls: [                                   
                    {id: "UserMobile",wid:"divTitle_UserMobile",type:"mustRegular", par: /^1[3-9][0-9]{9,9}$/, msg: "好像没这个号码？" }//
					,{id: "UserEmail",wid:"divTitle_UserEmail",type:"mustEmail", par:"", msg: "这个邮箱不存在吧？"}
                    ],
                success: function(){ 
                    },
                failed: function(msg){  
	                }
                });
			return ok;	
	
        }

