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

csdn高手们 帮小弟我看看 啊 嘿嘿

2012-01-11 
csdn高手们 帮我看看 啊 嘿嘿!我用正规表达式校验密码和重复密码遇到问题了,我是用控件校验,现在还没有办

csdn高手们 帮我看看 啊 嘿嘿!
我用正规表达式校验密码和重复密码遇到问题了,我是用控件校验,现在还没有办法解决!
<asp:Content   ID= "Content2 "   ContentPlaceHolderID= "MainContent "   Runat= "Server ">
<script   language= "javascript "     type   = "text/javascript ">
function   isPasswd(sTextId)   {  
        alert(sTextId);
        var   s   =document.all. "+   TextBox2.ClientID   +@ ".value;
        //   s   =   document.getElementById( "TextBox2 ");
     
var   patrn=/^(\w){6,20}$/;  
if   (!patrn.exec(s))  
{
       
        return   false;
}
else
{
        return   true;
}
}  


</script>
<table   width= "100% ">                    
<tr   class= "ta ">
      <td   class= "td "   align= "right "> <asp:Label   ID= "Label1 "   runat= "server "   Text= "用户名称: "   > </asp:Label> </td>
        <td   width= "75% "   class= "td "   > <font   color= "red "> <asp:TextBox   ID= "TextBox1 "   runat= "server "   MaxLength= "150 "   Width= "160px "> </asp:TextBox> <asp:RequiredFieldValidator   ID= "TextBox1Required "   runat= "server "   ControlToValidate= "TextBox1 "
                                                                                        ErrorMessage= "User   Name   is   required. "   ToolTip= "User   Name   is   required. "   > *请输入用户名 </asp:RequiredFieldValidator>
            </font>        
    </td> </tr>

<tr   class= "tb ">
        <td   class= "td "   align= "right "> <asp:Label   ID= "Label2 "   runat= "server "   Text= "用户密码: "> </asp:Label> </td>
        <td   class= "td ">
                <asp:TextBox   ID= "TextBox2 "  
                          runat= "server "   MaxLength= "50 "   TextMode= "Password "   Width= "160px "> </asp:TextBox>  
                          <font   color= "red "> [6-20位] </font>
                          <asp:RequiredFieldValidator   ID= "TextBox2Required "   runat= "server "  
                                  ControlToValidate= "TextBox2 "     ErrorMessage= "Password   is   required. "  


                                  ToolTip= "Password   is   required. "   ValidationGroup= "CreateUserWizard ">
                                  <font   color= "red "> * </font>
                                  </asp:RequiredFieldValidator> &nbsp;
                <asp:CustomValidator   ID= "CustomValidator1 "   runat= "server "   ClientValidationFunction= "isPasswd( 'TextBox2 ') "
                        ControlToValidate= "TextBox2 "     Display= "Dynamic "   ErrorMessage= "密码输入不合法,只能输入6-20个字母、数字、下划线 "> </asp:CustomValidator>
        </td>   </tr>      
        <tr   class= "ta ">
   
        <td   class= "td "   align= "right "> <asp:Label   ID= "Label3 "   runat= "server "   Text= "重复密码: "> </asp:Label> </td>
        <td   class= "td ">
<font   color= "red "> <asp:TextBox   ID= "TextBox3 "
                                                                                        runat= "server "   MaxLength= "50 "   TextMode= "Password "   Width= "160px "> </asp:TextBox>   [6-20位] </font>
<asp:RequiredFieldValidator   ID= "TextBox3dRequired "   runat= "server "   ControlToValidate= "TextBox3 "
                                                                                        ErrorMessage= "Confirm   Password   is   required. "   ToolTip= "Confirm   Password   is   required. "
                                                                                        ValidationGroup= "CreateUserWizard "> * </asp:RequiredFieldValidator> &nbsp;
                <asp:CustomValidator   ID= "CustomValidator2 "   runat= "server "   Display= "Dynamic "   ErrorMessage= "密码输入不合法,,只能输入6-20个字母、数字、下划线! "     ControlToValidate= "TextBox3 "   ClientValidationFunction= "isPasswd( 'TextBox3 ') "> </asp:CustomValidator>
                <asp:CompareValidator   ID= "PasswordCompare "   runat= "server "   ControlToCompare= "TextBox2 "


                                                                        ControlToValidate= "TextBox3 "   Display= "Dynamic "   ErrorMessage= "两次输入不一致! "
                                                                        ValidationGroup= "CreateUserWizard "> </asp:CompareValidator>     </td>
      </tr>

                                                     

  <tr   class= "tb ">
      <td   class= "td "   align= "right "> <asp:Label   ID= "Label5 "   runat= "server "   Text= "用户类型: "   > </asp:Label> </td>
        <td   width= "75% "   class= "td "   >
                <asp:DropDownList   ID= "DropDownList1 "   runat= "server ">
                </asp:DropDownList>
    </td> </tr>                          
       
   
<tr   class= "ta ">
        <td   class= "td "   align= "right "> <asp:Label   ID= "Label4 "   runat= "server "   Text= "用户描述: "> </asp:Label> </td>
        <td   class= "td ">
              <asp:TextBox   ID= "TextBox4 "           runat= "server "   TextMode= "MultiLine "   Width= "300 "   Height= "100 "> </asp:TextBox>

</td>
</tr>

   
   
  <tr   class= "ta ">
 
             
  <td   align= "center "   class= "td "   style= "height:   23px "> </td>
  <td   class= "td "   align= "left "   style= "height:   23px ">
              <asp:Button   ID= "Button1 "   runat= "server "   Text= "提交 "   Width= "85 "   OnClick= "Button1_Click1 "   />
              <asp:Button   ID= "Button2 "   runat= "server "   Text= "返回 "   Width= "85 "   />
</td>
</tr>


</table>  


</asp:Content>

[解决办法]
没有试过JS加验证控件一起用。
------解决方案--------------------


为什么要用JS,正则表达式直接写在html里不行啊?

热点排行