Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET
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
Shibiny565
Edited 2-Sep-12 22:24pm
v3
Comments
lukeer at 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 at 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)



Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 3 Sep 2012
Copyright © CodeProject, 1999-2014
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