﻿// JScript 文件

function CheckIsUser()
{
    if(GetObj('radIsNewUser').checked)
    {
        GetObj('tbNewUser').style.display = 'block';                
        GetObj('divOldUserPassword').style.display = 'none';
    }
    else
    {
        GetObj('tbNewUser').style.display = 'none';                
        GetObj('divOldUserPassword').style.display = 'inline';
    }
}

function CheckSubmit()
{
    GetObj('spanEmail').style.display = 'none';
    GetObj('spanCountry').style.display = 'none';
    GetObj('spanUserName').style.display = 'none';
    GetObj('spanUserName1').style.display = 'none';
    GetObj('spanPassword').style.display = 'none';
    GetObj('spanConfirmPassword').style.display = 'none';
    GetObj('spanOldUserPassword').style.display = 'none';
    
    if(!isEmail(GetObj('txtEmail').value.trim()))
    {
        GetObj('spanEmail').style.display = 'block';
        GetObj('txtEmail').focus();
        return false;
    }
    
    if(GetObj('radIsNewUser').checked)
    {
        if(GetObj('ddlCountry').value.trim().length < 1)
        {
            GetObj('spanCountry').style.display = 'inline';
            GetObj('ddlCountry').focus();
            return false;
        }
        if(GetObj('txtUserName').value.trim().length < 2)
        {
            GetObj('spanUserName').style.display = 'block';
            GetObj('txtUserName').focus();
            return false;
        }
        if(GetObj('txtUserName').value.trim() == GetObj('txtEmail').value.trim())
        {
            GetObj('spanUserName1').style.display = 'block';
            GetObj('txtUserName').focus();
            return false;
        }
        if(GetObj('txtPassword').value.trim().length < 6)
        {
            GetObj('spanPassword').style.display = 'block';
            GetObj('txtPassword').focus();
            return false;
        }
        if(GetObj('txtPassword').value.trim() != GetObj('txtConfirmPassword').value.trim())
        {
            GetObj('spanConfirmPassword').style.display = 'block';
            GetObj('txtConfirmPassword').focus();
            return false;
        }
        
        return confirm('-- 请确认您的注册信息 --　　　\r\n\r\nE-mail：' + GetObj('txtEmail').value + '\r\n用户名：' + GetObj('txtUserName').value + '\r\n密　码：' + GetObj('txtPassword').value);
    }
    else
    {
        if(GetObj('txtOldUserPassword').value.trim().length < 6)
        {
            GetObj('spanOldUserPassword').style.display = 'inline';
            GetObj('txtOldUserPassword').focus();
            return false;
        }
    }
}
function isEmail(strEmail)
{ 
    if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) 
        return true;
}
