如何在 WPF 的密码框中使用正则表达式
how to use Regex in password box in WPF
我想在 WPF 的密码框中测试我输入的密码,这样它唯一
aplhabets、数字和特殊字符.. 我做了以下代码 bt 循环直接转到 Else 循环。我应该怎么做才能使其正常运行?
Regex regex = new Regex("^(?=.+[A-Za-z])(?=.+\d)(?=.+[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$");
if (regex.IsMatch(txtPassword.ToString()))
{
MessageBox.Show("Data Saved Correctly");
}
else
{
txtPassword.Clear();
MessageBox.Show("Password should contain atleast one alphabet,number & special character");
}
txtPassword.ToString()
给出了文本框的字符串表示。
使用 txtPassword.Password
而不是 txtPassword.ToString()
。
祝你项目顺利:)
我想在 WPF 的密码框中测试我输入的密码,这样它唯一 aplhabets、数字和特殊字符.. 我做了以下代码 bt 循环直接转到 Else 循环。我应该怎么做才能使其正常运行?
Regex regex = new Regex("^(?=.+[A-Za-z])(?=.+\d)(?=.+[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,}$");
if (regex.IsMatch(txtPassword.ToString()))
{
MessageBox.Show("Data Saved Correctly");
}
else
{
txtPassword.Clear();
MessageBox.Show("Password should contain atleast one alphabet,number & special character");
}
txtPassword.ToString()
给出了文本框的字符串表示。
使用 txtPassword.Password
而不是 txtPassword.ToString()
。
祝你项目顺利:)