Solved

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

Posted on 2011-02-22
3
775 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 8

Expert Comment

by:jimsweb
ID: 34958394
0
 
LVL 12

Accepted Solution

by:
Praveen Kumar earned 500 total points
ID: 34958411
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
ID: 34958681
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 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