Solved

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

Posted on 2011-02-22
3
774 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
ID: 34958394
0
 
LVL 12

Accepted Solution

by:
Mamtha1982 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reactjs with .NET 3 70
disable data migrations in visual studio 2017 4 42
How to show selected values from drop down and text box on the popup? 25 26
Return array 3 20
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

735 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