discoverx

博客园 首页 新随笔 联系 订阅 管理

 

    function checkdata()
            
{
                
if(document.getElementById("TB_UserName").value=="" )
                
{
                    alert(
"注册帐号不能为空"); 
                    
return false;
                }

                
                
if(document.getElementById("TB_PassWord").value=="" )
                
{
                    alert(
"用户密码不能为空"); 
                    
return false;
                }

                
if(document.getElementById("TB_Password2").value=="" )
                
{
                    alert(
"密码确认不能为空"); 
                    
return false;
                }

                
if(document.getElementById("TB_Password2").value!=document.getElementById("TB_PassWord").value )
                
{
                    alert(
"用户密码与密码确认不一致!"); 
                    
return false;
                }

                
if(document.getElementById("TB_Name").value=="" )
                
{
                    alert(
"真实姓名不能为空"); 
                    
return false;
                }

                
                
                
if(document.getElementById("TB_Email").value=="" )
                
{
                    alert(
"电子信箱不能为空"); 
                    
return false;
                }

                
else
                
{
                    
//验证电子信箱            
                    
                    var re
=/^\w+@\w+\.\w{2,3}/;
                    var str
=document.getElementById("TB_Email").value;
                    var r
=str.match(re);
                    
if(r==null)
                    
{
                        alert(
"邮箱可以帮你找回密码,请认真填写"); 
                        
return false;
                    }

                }

                
if(document.getElementById("TB_Birthday").value=="" )
                
{
                    alert(
"出生日期不能为空"); 
                    
return false;
                }

                
else
                
{
                    var re
=/^\d{4}-\d{1,2}-\d{1,2}$/;
                    var str
=document.getElementById("TB_Birthday").value;
                    var r
=str.match(re);
                    
if(r==null)
                    
{
                        alert(
"注意日期格式:1980-01-01"); 
                         
return false;
                    }
    
                }

                
return true;
            }

function Eventbody() { document.all("Btn_Post").attachEvent('onclick',checkdata) }
这个是body 的 onload=" Eventbody()" 事件
给服务器控件按钮Btn_Post添加一个事件

posted on 2007-05-22 15:38  discoverx  阅读(230)  评论(0编辑  收藏  举报