//表单验证函数
<!--
//注册验证

       //对象内容是否为空
function IsEmpty(aTextField) {
    if ((aTextField.value.length==0) || (aTextField.value==null)) {
        return true;
    }else {
        return false;
    }
}

//是否阅读服务协议
function agree_onclick(){
    var theForm = document.forms['user_register'];
    if (!theForm) {  theForm = document.Form1;}
    theForm.agree.checked==''
    if(theForm.agree.checked==''){
        //如果为空,则将提交设为不可用
        theForm.op.disabled=true;
    }else{
        theForm.op.disabled=false;
    }
}

//检查用户名
function UserExist(){
    var theForm = document.forms['user_register'];
    //
    if(IsEmpty(theForm['edit[name]']))
    {
        alert('请输入注册账户!');
        theForm['edit[name]'].focus();
        return false;
    }
    var name = theForm['edit[name]'].value;
    window.open('register_check.php?name='+name);
}

//验证表单
function Validator(){
    var theForm = document.forms['user_register'];
    if (!theForm) {theForm = document.Form1;}


    if(IsEmpty(theForm['edit[name]']))
    {
    alert('请输入注册账户!');
    theForm['edit[name]'].focus();
    return false;
    }
    if(!test_RegisterName(theForm['edit[name]'].value))
    {
    alert('用户名首字符必须是字母，其后只能含有字母、数字和下划线，且长度在4到20位内！');
    theForm['edit[name]'].focus();
    return false;
    }
    if(IsEmpty(theForm['edit[pass]']))
    {
    alert('请输入密码!');
    theForm['edit[pass]'].focus();
    return false;
    }
    if(!test_Password(theForm['edit[pass]'].value))
    {
    alert('密码最小长度为 5 位！最大长度20位！同时密码中不能有逗号出现!');
    theForm['edit[pass]'].focus();
    return false;
    }
    if(IsEmpty(theForm['edit[pass2]']))
    {
    alert('请再次输入密码!');
    theForm['edit[pass2]'].focus();
    return false;
    }
    if(theForm['edit[pass2]'].value != theForm['edit[pass]'].value)
    {
    alert('两次输入密码必须一致！！');
    theForm['edit[pass2]'].focus();
    return false;
    }
    if(IsEmpty(theForm['edit[mail]']))
    {
    alert('请输入邮件地址!');
    theForm['edit[mail]'].focus();
    return false;
    }
    if(!test_Email(theForm['edit[mail]'].value))
    {
    alert('请输入正确的Email地址！');
    theForm['edit[mail]'].focus();
    return false;
    }

    if(IsEmpty(theForm.number))
    {
    alert('请输入验证码!');
    theForm.number.focus();
    return false;
    }

    if(!theForm.agree.checked)
    {
    alert('必须同意注册条款才可以注册!');
    theForm.agree.focus();
    return false;
    }

    return true;
}

function test_RegisterName(strInput){
    var myReg = /^[a-zA-Z][a-zA-Z0-9_]{3,19}$/;
    if(myReg.test(strInput)) return true;
    return false;
}

function test_Password(strInput){
    var myReg = /^[^\n,]{5,20}$/;
    if(myReg.test(strInput)) return true;
    return false;
}

function test_Email(strEmail){
    var myReg = /^([\S])+[@]{1}([\S])+[.]{1}(\S)+$/;
    if(myReg.test(strEmail)) return true;
    return false;
}


function trim(text)  //删除前尾空格
{
    return text.replace(/^\s+/i, '').replace(/\s+$/i, '');
}



		//-->

		<!--  登录框提示层 开始   -->
<!-- 
//登录验证
		//检查是否记住登录名
function $(id){
	return document.getElementById(id);
}
function GetCookie(_Name)
{
	var Res = eval('/'+_Name+'=([^;]+)/').exec(document.cookie);
	return Res == null ? false : Res[1];
}

function initUserName(){
	var loginname = GetCookie('cREMloginname');
	if(loginname != false){
		$('loginname').value = decodeURIComponent(loginname);
		$('save').checked = "checked";
	}
	passcardOBJ.init(
	// FlashSoft 注意,最好这个input的autocomplete设定为off

	// 需要有下拉框的input对象
	document.getElementById("loginname"),
	{
		// 鼠标经过字体颜色
		overfcolor: "#999",
		// 鼠标经过背景颜色
		overbgcolor: "#e8f4fc",
		// 鼠标离开字体颜色
		outfcolor: "#000000",
		// 鼠标离开背景颜色
		outbgcolor: ""
	},
	// 输入完成后,自动需要跳到的input对象[备选]
	document.getElementById("passcode"));
}
//window.onload = initUserName;

 -->
 <!--  登录框提示层 结束  -->
