首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

check为什么会出错(IE)解决方案

2012-02-10 
check为什么会出错(IE)%@pagecontentType text/html %%@pagepageEncoding UTF-8 %!DOCTYPEhtml

check为什么会出错(IE)
<%@page   contentType= "text/html "%>
<%@page   pageEncoding= "UTF-8 "%>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
        <head>
                <script>
function   check(){
}
check.prototype={
pattern_user_name:/[a-z]+/,
checkUserName:function(){
var   user_name=document.getElementById( "username ");
if(this.pattern_user_name.test(user_name.value)){
window.alert( "user   name   does   not   match\n ");
}
                                else{
                                alert( "pp ");
                                }
},
}
var   validate=new   check();

                </script>
                <title> Untitled   Document </title>
               
                <meta   http-equiv= "Content-Type "   content= "text/html;   charset=UTF-8 "   />
                <link   href= "register.css "   rel= "stylesheet "   type= "text/css "   />
        </head>
        <body   class= "sub ">
                <form   action= " "   method= "post "   name= "register "   id= "register ">
                        <table   border= "0 "   cellpadding= "8 "   id= "outertable ">
                                <tr>
                                        <td   colspan= "3 "   class= "HeaderColor ">                 <h4> 注册Padoo </h4>             </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">
                                        <td   height= "52 "   nowrap= "nowrap "   class= "LabelColor "   style= "text-align:   right ">
                                        <label   for= "username ">   用户* </label>             </td>


                                        <td   colspan= "2 "   class= "TitleColor ">
                                                <input   type= "text "   id= "username "   name= "textfield "   />
                                                <br   />                
                                        <span   class= "small "> *数字或字母或下划线或连接线的组合 </span> </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">
                                        <td   style= "text-align:   right "   class= "LabelColor ">
                                        <label   for= "password ">   密码* </label>             </td>
                                        <td   colspan= "2 "   class= "TitleColor ">                 <input   type= "text "   id= "password "   name= "textfield2 "   />             </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">
                                        <td   style= "text-align:   right "   class= "LabelColor ">
                                        <label   for= "confirmpassword ">   确认密码* </label>             </td>
                                        <td   colspan= "2 "   class= "TitleColor ">
                                                <input   type= "text "   id= "confirmpassword "   name= "textfield3 "   />
                                                <br   />                


                                        <span   class= "small "> *有的可显示的字符均可 </span>             </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">
                                        <td   style= "text-align:   right "   class= "LabelColor "> 姓名 </td>
                                        <td   width= "43% "   class= "TitleColor ">
                                        <label   for= "first "> 姓氏 </label>                 <input   type= "text "   id= "first "   name= "textfield4 "   />             </td>
                                        <td   width= "46% "   class= "TitleColor ">
                                        <label   for= "last "> 名字 </label>                 <input   type= "text "   id= "last "   name= "textfield5 "   />             </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">
                                        <td   style= "text-align:   right "   class= "LabelColor ">
                                        <label   for= "email ">   Email </label>             </td>
                                        <td   colspan= "2 "   class= "TitleColor ">                 <input   type= "text "   id= "email "   name= "textfield6 "   size= "50 "   />             </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">


                                        <td   style= "text-align:   right "   class= "LabelColor "> 性别 </td>
                                        <td   colspan= "2 "   class= "TitleColor ">                 <p>
                                                        <label   for= "male "> 男 </label>
                                                        <input   type= "radio "   id= "male "   name= "radiobutton1 "   value= "radiobutton "   />
                                                        女
                                                        <label   for= "female ">   </label>
                                                        <input   type= "radio "   id= "female "   name= "radiobutton1 "   value= "radiobutton "   />
                                        </p>             </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">
                                        <td   style= "text-align:   right "   class= "LabelColor "> 出生日期 </td>
                                        <td   colspan= "2 "   class= "TitleColor ">                 <table   border= "0 "   cellspacing= "2 "   cellpadding= "0 ">
                                                        <tr   style= "text-align:   left ">
                                                                <td   class= " ">


                                                                        <label   for= "month "> 月 </label>
                                                                <input   type= "text "   id= "month "   name= "textfield7 "   size= "2 "   />                         </td>
                                                                <td   class= " ">
                                                                        <label   for= "day "> 日   </label>
                                                                <input   type= "text "   id= "day "   name= "textfield8 "   size= "2 "   />                         </td>
                                                                <td   class= " ">
                                                                        <label   for= "year "> 年 </label>
                                                                <input   type= "text "   id= "year "   name= "textfield9 "   size= "4 "   />                         </td>
                                                        </tr>
                                        </table>             </td>
                                </tr>
                                <tr   style= "vertical-align:   top ">


                                        <td   style= "text-align:   right "   class= "LabelColor "> 校验* </td>
                                        <td   width= "43% "   class= "TitleColor ">
                                                <label   for= "first "> </label>                
                                        <input   type= "text "   id= "first "   name= "textfield4 "   />             </td>
                                        <td   width= "46% "   class= "TitleColor ">
                                                <label   for= "last "> </label>                
                                        <img   src= " "   id= "checkpic "/>             </td>
                                </tr>
                                <tr   style= "vertical-align:   top "   class= "FooterColor ">
                                        <td   colspan= "3 ">
                                        <input   type= "button "   name= "SubmitName "   value= "提交 "   onclick= "validate.checkUserName() "   />             </td>
                                </tr>
                        </table>
                </form>
        </body>
</html>


[解决办法]
check.prototype={
pattern_user_name:/[a-z]+/,
checkUserName:function(){
var user_name=document.getElementById( "username ");
if(this.pattern_user_name.test(user_name.value)){
window.alert( "user name does not match\n ");
}
else{
alert( "pp ");
}
}, //这个逗号有啥用啊,去掉试试
}

热点排行