Regular expression for password validation in JavaScript

 
Following example show that how we can validate password with the help of Regular Expression that have these validation:

Must be at least 10 characters
Must contain at least one one lower case letter,
one upper case letter,
one digit and one special character
Valid special characters are – @#$%^&+=

  <html>  
      <head>  
          <script type="text/javascript">  
          var reg = /^.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$/;  
          function PhoneValidation(phoneNumber)
          {  
            var OK = reg.exec(phoneNumber.value);  
            if (!OK)  
              window.alert("phone number isn't  valid");  
            else  
              window.alert("phone number is  valid");  
          }  
        </script>  
      </head>  
 
      <body>  
        <p>Enter your phone number and then press Enter.</p>  
        <form action="">  
          <input name="txtPhone" onchange="PhoneValidation(this);">  
        </form>  
      </body>  
    </html>

More on Regular Expressions