Click here to Skip to main content
12,950,399 members (61,942 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Using java script How to validate the password in asp.net c#


I want some characters,numbers,Special characters,
Posted 2-Sep-12 21:34pm
Shibiny581
Updated 2-Sep-12 22:24pm
v3
Comments
lukeer 3-Sep-12 3:59am
   
Don't post the same question again[^]. Use the "Improve question" link instead. It's located directly beneath your original question. Provide further information to help others to help you.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

try this reg expression
 
/^([a-zA-Z0-9~!@#$%^&*]*)$/
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Shibiny 3-Sep-12 4:24am
   
Using java script How to validate the password in asp.net c#


I want some characters,numbers,Special characters,
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

This is what I did some time back. A simple point based approach.

function CheckPassword()
       {
           var password = document.getElementById('<%=txtPassword.ClientID %>').value;
           var txtPassword = document.getElementById('<%=lblPasswordMeter.ClientID %>');
 
           var score = 0;
 
           if(password.length < 8)
           {
               //this is a very weak password
               txtPassword.style.color = "Red";
               txtPassword.innerHTML = "Too short";
               return;
 
           }
 
           //lets check for small letters
           for(var s=0; s<password.length; ++s)
           {
               if(password.charCodeAt(s) >= 'a'.charCodeAt(0) && password.charCodeAt(s) <= 'z'.charCodeAt(0))
               {
                   score += 1;
                   break;
               }
           }
 
           //lets check for capital letters
           for(var s=0; s<password.length; ++s)
           {
               if(password.charCodeAt(s) >= 'A'.charCodeAt(0) && password.charCodeAt(s) <= 'Z'.charCodeAt(0))
               {
                   score += 1;
                   break;
               }
           }
 
           //Lets check for numbers
           for(var s=0; s<password.length; ++s)
           {
               if(password.charCodeAt(s) >= '0'.charCodeAt(0) && password.charCodeAt(s) <= '9'.charCodeAt(0))
               {
                   score += 1;
                   break;
               }
           }
 
          //lets now calculate final score to declare the results
          switch(score)
          {
           case 0:
           case 1:
               txtPassword.style.color = "Red";
               txtPassword.innerHTML = "too weak";
           break;
           case 2:
               txtPassword.style.color = "Orange";
               txtPassword.innerHTML = "average";
           break;
           case 3:
               txtPassword.style.color = "Green";
               txtPassword.innerHTML = "strong";
           break;
          }
       };
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,829
CHill60 3,460
Maciej Los 2,953
Jochen Arndt 1,975
ppolymorphe 1,820


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100