没看到调用该函数呀<input   name= "validate1 "   type= "text "   size= "10 "   maxlength= "4 " onblur="valid();"   /> 

解决方案 »

  1.   

    你都没有调用valid()当然就没用了阿
      

  2.   

    还有楼主的html格式<form> <body></body></form> body在form里判断为空函数一般在<input   type= "submit "   name= "Submit "   value= "登录 "   />调用
      

  3.   

    <script   language= "javascript "> 
    function   veri()   { 
    var   sourcenum   =   "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "; 
    var   siglenum   =   " "; 
    var   checknum   =   " "; 
    var   index   =0; 
    var   result   =   " "; 
    for   (i=0;   i <8;   i++)   { 
    //随机生成0-35个数字 
    index   =   (Math.random()*100)%35; 
    //截取单个字符 
    siglenum=sourcenum.substring(index,index+1); 
    checknum   +=siglenum; 
    i++; 

    document.form1.validation_txt.value   =   checknum; 

    <!-- 
    function   deal()   { 
    //获得一个字符串 
    result.innerHTML   =   veri(); 

    --> 
    function   valid()   { 
    if   (document.form1.validate1.value   ==   " ")   { 
    alert( "验证码不能为空! "); 
    document.form1.validate1.focus(); 
    return   false; 

    if   (document.form1.validate1.value   !=   document.form1.validation_txt.value)   { 
    alert( "验证码错误! "); 
    document.form1.validate1.focus(); 
    return   false; 


    else{
    document.location.href=""//跳到下个页面
    }

    </script> 
    </head>    
    <form   name= "form1"  action=""> 
    <body   onload= "veri()"> 

    <table   width= "50% "   height= "179 "   border= "1 "   align= "center "   cellpadding= "0 "   cellspacing= "0 "> 
        <tr> 
            <td   height= "28 "   colspan= "2 "> <div   align= "center "   class= "STYLE1 "> 登陆页面 </div> 
    </td> 
        </tr> 
        <tr> 
            <td   width= "33% "   height= "37 "> <div   align= "right "> 用户名: </div> </td> 
            <td   width= "67% "> <input   name= "username "   type= "text "   id= "username "   /> </td> 
        </tr> 
        <tr> 
            <td   height= "38 "> <div   align= "right "> 密   码: </div> </td> 
            <td> <input   name= "password "   type= "password "   id= "password "   /> </td> 
        </tr> 
        <tr> 
            <td   height= "38 "> <div   align= "right "> 验证码: </div> </td> 
            <td> <input   name= "validate1 "   type= "text "   size= "10 "   maxlength= "4 "   /> 
    <input   type= "text "   name= "validation_txt "   size= "4 "   maxlength= "4 "   readonly= "true "/> &nbsp;   </td> 
        </tr> 
        <tr> 
            <td   colspan= "2 "> <div   align= "center "> 
                <input   type= "button "   name= "Submit"   value= "登录 "  onclick="valid()"> 
            </div> </td> 
        </tr> 
    </table> 

    </body> 
    </form>

    </html>