Solved

how can i validate password texbox in C#.net windows application ??

Posted on 2011-02-22
3
770 Views
Last Modified: 2012-06-21
i want to validate password that only 8 chars long and accept (0-9,a-z and special characters).
i want to use regular expressions in this , and also using textbox validating event and textbox validated event , so how can i do that ?

for ex..

 private void txtPassword_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
                // here coding ...
        }

        private void txtPassword_Validated(object sender, EventArgs e)
        {
                //here coding...
        }

give me some suggestions ...
0
Comment
Question by:Parth48
3 Comments
 
LVL 8

Expert Comment

by:jimsweb
Comment Utility
0
 
LVL 12

Accepted Solution

by:
Mamtha1982 earned 500 total points
Comment Utility
private void txtPassword_Validating(object sender,
                         System.ComponentModel.CancelEventArgs e)
{
   if(!ValidText(txtPassword.Text))
   {
      // Cancel the event and select the text to be corrected by the user.
      e.Cancel = true;
      textBox1.Select(0, textBox1.Text.Length);

   }
}

 private void txtPassword_Validated(object sender, EventArgs e)
        {
                //here coding...
        }

public bool ValidText(string stringValue)
{
   if(stringValue.Length != 8)
   {
           return false;
   }

return true;

}




0
 
LVL 8

Expert Comment

by:Anurag Agarwal
Comment Utility
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now