验证asp.net中的密码 [英] validate password in asp.net
本文介绍了验证asp.net中的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何在asp.net中验证密码长度?
并且还比较密码nd确认密码..
解决方案
有一看:
如何使用ASP.NET验证控件验证用户输入 [ ^ ]
试试这段代码:
public bool IsPasswordsEqual( string password1, string password2)
{
if (password1.Equals(password2))
{
return true ;
}
返回 false ;
}
在提交按钮点击事件或 confirmmpassword 文本框离开事件时使用此方法
为
if (!IsPasswordsEqual(Textbox1.Text,TextBox2.Text))
{
MessageBox.Show( 在)中输入相同的密码;
}
< asp:标签 ID < span class =code-keyword> = lbl_password runat = server CssClass = 标签 文字 = 密码 > < / asp:标签 >
< div class = 清洁 >
< / div >
< asp:TextBox ID = radtxtPassword runat = server TextMode = 密码 CssClass = textbox ValidationGroup = < span class =code-keyword> RegisterCheck >
< / asp:TextBox >
< ; asp:RequiredFieldValidator ID = RequiredFieldValidator1 runat = server ControlToValidate = radtxtPassword
ValidationGroup = RegisterCheck > < span class =code-keyword>< / asp:RequiredFieldValidator >
< asp:RegularExpressionValidator ID = valPassword runat = server ControlToValidate = radtxtPassword
ErrorMessage = 最小密码长度为6 ValidationExpression = ^([a-zA-Z0-9 @#
%^& + = *] {6,30})
how i can validate password length in asp.net??
and also compare password nd confirm password..
解决方案
Have a look:
How to Use the ASP.NET Validation Control to Validate the User Input[^]
Try this code:
public bool IsPasswordsEqual(string password1, string password2) { if (password1.Equals(password2)) { return true; } return false; }
use this method on submit button click event or confirmpassword textbox leave event
as
if(!IsPasswordsEqual(Textbox1.Text,TextBox2.Text)) { MessageBox.Show("Enter same password in both"); }
Refer: Compare password[^]
<asp:Label ID="lbl_password" runat="server" CssClass="Label" Text="Password"></asp:Label> <div class="cleaner"> </div> <asp:TextBox ID="radtxtPassword" runat="server" TextMode="Password" CssClass="textbox" ValidationGroup="RegisterCheck"> </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="radtxtPassword" ValidationGroup="RegisterCheck" ></asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="valPassword" runat="server" ControlToValidate="radtxtPassword" ErrorMessage="Minimum password length is 6" ValidationExpression="^([a-zA-Z0-9@#
%^&+=*]{6,30})
这篇关于验证asp.net中的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文