﻿$(document).ready(function(){$.formValidator.initConfig({formid:"form1",onerror:function(msg){},onsuccess : function (){$("#btnEnterCheck").val('提交中');return true}});
    $("#txtMail").formValidator({onshow : "邮箱作为您的游戏账号，可通过该邮箱自动找回密码",onfocus : "邮箱作为您的游戏账号，并且为密码找回邮箱",oncorrect : "该邮箱用户名可使用"}).regexValidator({regexp:"email",datatype:"enum",onerror:"邮箱用户名格式不正确"}).ajaxValidator({type : "POST",url : "../Wbsrv/AjaxCheckUserHandler.ashx?rand="+Math.random(),async : true,success : function (data) {if(data=="true"){return true;}else if(data=="false"){return false;}else{alert('页面已超时，请刷新页面后重新注册');}},button : $("#btnEnterCheck"),error : function (){alert("服务器没有返回数据，可能是服务器繁忙，请稍候再试！");},onerror : "用户已存在，请重新输入！",onwait : "正在对邮箱用户名进行校验，请稍候..."});
    $("#txtPwd").formValidator({onshow : "请输入密码，密码由6-20位字母及数字组成，区分大小写",onfocus : "请输入密码，密码由6-20位字母及数字组成，区分大小写",oncorrect : "填写正确"}).inputValidator({min:6,max:20,empty : {leftempty:false,rightempty:false,emptyerror:"密码两边不能有空符号"},onerror : "密码格式不正确，由6-20位字母及数字组成，区分大小写"}).regexValidator({regexp : "pwd",datatype : "enum",onerror : "密码只能由数字和字母组成，区分大小写" });
    $("#txtConPwd").formValidator({onshow : "请输入确认密码，密码由6-20位字母及数字组成，区分大小写",onfocus : "请输入确认密码，密码由6-20位字母及数字组成，区分大小写",oncorrect : "填写正确"}).inputValidator({min:6,empty : {leftempty:false,rightempty:false,emptyerror:"确认密码两边不能有空符号"},onerror : "确认密码格式不正确，由6-20位字母及数字组成，区分大小写"}).compareValidator({desid : "txtPwd",operateor: "=",onerror :"两次密码不一致，请确认"});
    $("#txtRealName").formValidator({onshow : "为了您的账号安全，请输入您的真实姓名",onfocus : "为了您的账号安全，请输入您的真实姓名",onerror : "真实姓名必须填写"}).regexValidator({regexp : "chinese",datatype : "enum",onerror : "请输入正确的真实姓名" });
    $("#txtCardId").formValidator({onshow : "关系您的账号安全及<a href=\"fcm.html\" target=\"_blank\"><font color=\"red\">防沉迷系统</font></a>，请输入您的身份证号码",onfocus : "身份证号一经填写不能修改，请认真填写",onerror : "身份证号必须填写"}).functionValidator({fun:isCardID});
    $("#question").formValidator({onshow : "请选择您的密码保护问题，方便对您的账号进行安全保护",onfocus : "请选择您的密码保护问题，方便对您的账号进行安全保护",onerror : "密码保护资料必须设置",oncorrect : "密保问题选择完成"}).inputValidator({min:1,onerror : "请选择您的密码保护问题"});
    $("#custom_question").formValidator({onshow:"请输入您的自定义问题",onfocus:"请输入您的自定义问题",onerror : "保护问题必须在4-20位字符之间",oncorrect:"填写完成"}).inputValidator({min:4,max:20,onerror : "保护问题必须在4-20位字符之间"});
    $("#txtAnswer").formValidator({onshow : "为了您的账号安全，请填写您的密码保护答案",onfocus : "为了您的账号安全，请填写您的密码保护答案", onerror : "答案必须在2-20位字符之间",oncorrect:"填写完成"}).inputValidator({min:2,max:20,onerror : "答案必须在2-20位字符之间"});
    $("#txtTgyIdNumber").formValidator({onshow:"此处为推广员填写",onfocus :"此处为推广员填写",onerror :"推广码必须为字母加数字",oncorrect:"填写完成",empty:true}).regexValidator({regexp:"pwd",datatype:"enum",onerror:"推广码格式不正确！"}).inputValidator({min:5,max:10,onerror : "推广码必须字母加数字"});
    $("#txtCode").formValidator({onshow : "请输入正确的验证码",onfocus : "请输入正确的验证码",oncorrect : "填写完成"}).inputValidator({min:4,max:4,empty : {leftempty:false,rightempty:false,emptyerror:"请输入正确的验证码"},onerror : "请输入正确的验证码"}).ajaxValidator({type : "POST",url : "../Wbsrv/AjaxCheckValiCodeHandler.ashx?rand="+Math.random(),async : true,success : function (data) {if(data=="true"){return true;}else{$("#txtCode").click;return false;}},button : $("#btnEnterCheck"),onerror : "验证码错误，请<a href='javascript:void(0)' onclick='ChangeValiedCode()'>点击刷新</a>后重新输入！",onwait : "正在对验证码进行校验，请稍候..."});
    $(":checkbox[name='checkInfo']").formValidator({tipid : "checkInfoTip",onshow:"只有接受协议才能注册",onfocus:"只有接受协议才能注册",oncorrect:"同意"}).inputValidator({ min:1,max:1,onerror:"只有接受协议才能注册"});
    //$("#txtHTML").formValidator({onshow:"请填写回复内容，长度在5-300位字符之间",onfocus:"请填写回复内容，长度在5-300位字符之间",oncorrect:"Success"}).inputValidator({min:5,max:300,onerror: "请填写回复内容，长度在5-300位字符之间"}).regexValidator({regexp:"isHtml",datatype:"enum",onerror:"不能含有特殊字符"});
    $("#btnEnterCheck").click(function(){jQuery.formValidator.pageIsValid();});
});
function checkQuestion(obj){
    if(obj.value=='0000'){
        $("#custom_question").unFormValidator(false);
        $('#my_question').show();
        $('#questionTip').hide();
        $("#custom_question").focus();
    }else{
        $("#custom_question").unFormValidator(true);
        $('#my_question').hide();
        $('#questionTip').show();
    }
}
