title: Javascript regular expression password validation having special characters
body: <p>I am trying to validate the password using regular expression. The password is getting updated if we have all the characters as alphabets. Where am i going wrong ? is the regular expression right ?</p>
  
  <pre><code>function validatePassword() {
      var newPassword = document.getElementById('changePasswordForm').newPassword.value;
      var minNumberofChars = 6;
      var maxNumberofChars = 16;
      var regularExpression  = /^[a-zA-Z0-9!@#$%^&amp;*]{6,16}$/;
      alert(newPassword); 
      if(newPassword.length &lt; minNumberofChars || newPassword.length &gt; maxNumberofChars){
          return false;
      }
      if(!regularExpression.test(newPassword)) {
          alert("password should contain atleast one number and one special character");
          return false;
      }
  }
  </code></pre>