Solved

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

Posted on 2011-02-22
3
776 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

636 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