﻿// JScript 文件
function getSchool(DistrictID)
{    
    Edulife.BLL.ClientValidator.getSchool(DistrictID,getSchool_callback);
}
function getSchool_callback(res)
{
    var dt = res.value;
    clearOption($(droSchool));
    for(var i=0;i<dt.Rows.length;i++)
        addOption($(droSchool),dt.Rows[i].School,dt.Rows[i].SchoolId);
    if(dt.Rows.length==0)
        addOption($(droSchool),"请选择学校","0");
}
function getSchoolx(DistrictID)
{    
    Edulife.BLL.ClientValidator.getSchool(DistrictID,getSchoolx_callback);
}
function getSchoolx_callback(res)
{
    var dt = res.value;
    clearOption($(droSchool));
    for(var i=0;i<dt.Rows.length;i++)
        addOption($(droSchool),dt.Rows[i].School,dt.Rows[i].School);
    if(dt.Rows.length==0)
        addOption($(droSchool),"请选择学校","");
}

function UserIdValidator(source, arguments)
{
    var re=/^[a-zA-Z]{1}\w{4,19}$/;
    if(arguments.Value.match(re)==null)
    {
        source.innerHTML="用户名只能输入5-20个英文字符或数字，且必须以英文字符开头";
        arguments.IsValid = false;
    }
    else if(Edulife.BLL.ClientValidator.checkUserId(arguments.Value).value)
    {
        source.innerHTML="用户名已被注册";
        arguments.IsValid = false;
    }
    else
        arguments.IsValid = true;
}
function UserIdValidator2(source, arguments)
{
    var re=/^.{5,20}$/;
    if(arguments.Value.match(re)==null)
    {
        source.innerHTML="用户名只能输入5-20个字符";
        arguments.IsValid = false;
    }
    else if(Edulife.BLL.ClientValidator.checkUserId(arguments.Value).value)
    {
        source.innerHTML="用户名已被注册";
        arguments.IsValid = false;
    }
    else
        arguments.IsValid = true;
}
function UserIdAliveValidator(source, arguments)
{
    var re=/^[a-zA-Z]{1}\w{4,19}$/;
    if(arguments.Value.match(re)==null)
    {
        source.innerHTML="用户名只能输入5-20个英文字符或数字，且必须以英文字符开头";
        arguments.IsValid = false;
    }
    else if(!Edulife.BLL.ClientValidator.checkUserId(arguments.Value).value)
    {
        source.innerHTML="用户不存在";
        arguments.IsValid = false;
    }
    else
        arguments.IsValid = true;
}
function StudyCardValidator(source, arguments)
{
    arguments.IsValid = Edulife.BLL.ClientValidator.checkStudyCard(arguments.Value).value;
}
function SourceNoValidator(source, arguments)
{
    arguments.IsValid = Edulife.BLL.ClientValidator.checkSourceNo(arguments.Value).value;
}
function EmailValidator(source, arguments)
{
    var re=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    if(arguments.Value.match(re)==null)
    {
        source.innerHTML="请输入正确的Email地址";
        arguments.IsValid = false;
    }
    else if(!Edulife.BLL.ClientValidator.checkEmail($(txtUserId).value,arguments.Value).value)
    {
        source.innerHTML="Email和用户名不匹配";
        arguments.IsValid = false;
    }
    else
        arguments.IsValid = true;
}
function checkPassWord(source, arguments)
{
    var re=/^.{6,}$/;
    if(arguments.Value.match(re)==null)
    {
        source.innerHTML="请输入一个较长的密码";
        arguments.IsValid = false;
    }
    else if(!Edulife.BLL.ClientValidator.checkPassWord(arguments.Value).value)
    {
        source.innerHTML="密码错误";
        arguments.IsValid = false;
    }
    else
        arguments.IsValid = true;
}

function checkTel(source, arguments)
{
    arguments.IsValid = Edulife.BLL.ClientValidator.checkTel(arguments.Value).value;
}

function checkMobilePhone(source, arguments)
{
    arguments.IsValid = Edulife.BLL.ClientValidator.checkMobilePhone(arguments.Value).value;
}

function getSchool2()
{    
    var area=document.getElementById("ddlDistrict");
	if(area.value!="")
        Edulife.BLL.ClientValidator.getSchool(area.value,getSchool_callback2);
}
function getSchool_callback2(res)
{
    var dt = res.value;
    document.getElementById("ddlSchool").length=0;　
	document.getElementById("ddlSchool").options.add(new Option("请选择学校","0"));　　　 
	for(var i=0; i<dt.Rows.length; i++)
	{
	    var name=dt.Rows[i]["School"];
		var id=dt.Rows[i]["SchoolId"];
		document.getElementById("ddlSchool").options.add(new Option(name,id));
    }
}

function getSchool3(districtID)
{    
	if(districtID!="")
        Edulife.BLL.ClientValidator.getSchool(districtID,getSchool_callback3);
}
function getSchool_callback3(res)
{
    var dt = res.value;
    document.getElementById("ctl00_droSchool").length=0;　
	document.getElementById("ctl00_droSchool").options.add(new Option("请选择学校","0"));　　　 
	for(var i=0; i<dt.Rows.length; i++)
	{
	    var name=dt.Rows[i]["School"];
		var id=dt.Rows[i]["SchoolId"];
		document.getElementById("ctl00_droSchool").options.add(new Option(name,id));
    }
}
