Contains
is the wrong method.
Here:
bool isValidPassword = passBox.Password.Any(char.IsDigit)
&& passBox.Password.Any(char.IsLetter);
Question
I'm creating a WPF window for insert user, I'm using PasswordBox
for user type your password, but I have not ideas what I can put in passBox.Password.Contains( )
I need help for how to check this PasswordBox
contains chars and numbers?
Solution
Contains
is the wrong method.
Here:
bool isValidPassword = passBox.Password.Any(char.IsDigit)
&& passBox.Password.Any(char.IsLetter);
OTHER TIPS
You can use regular expression to check it. It will be something like this:
using System.Text.RegularExpressions;
Regex regex = new Regex(@"^.*(?=.{4,10})(?=.*\d)(?=.*[a-zA-Z]).*$");
if (regex.Match(passwordBox1.Password).Success)
{
//the password match the rule
}
The above regular expression matches if:
You can modify it to fit your needs