Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-22
3
Medium Priority
?
779 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 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

704 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