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

x
?
Solved

Check password has at least 1 uppercase, 1 lowercase , 1 number and 8 characters minimum

Posted on 2009-04-09
2
Medium Priority
?
1,673 Views
Last Modified: 2012-05-06
Hi,

I'm just trying to validate a password field.
Can someone please help with an expression to validate that the field has:
1 uppercase, 1 lowercase , 1 number and 8 characters minimum

Thanks.
0
Comment
Question by:mrduckers
[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
  • 2
2 Comments
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 1000 total points
ID: 24112740
something on these grounds:
<HTML>
<HEAD>

<script Language="JavaScript">

function checkPassword () {

      var strng  = document.passwordResetForm.newpass.value;
      var strng2 = document.passwordResetForm.verifypass.value;
      var errMsg = "";
      if (strng == "") {
            errMsg = "Enter a password.\n";
      }

      if ((strng.length < 6) || (strng.length > 16)) {
            errMsg += "The password is the wrong length\n";
      }
      if (/[^a-zA-Z0-9]/.test(strng)) {
            errMsg += "The password contains illegal characters.\n";
      }

      if (!/[0-9]/.test(strng) || !/[a-zA-Z]/.test(strng)) {
            errMsg += "The password must contain at least one letter and one numeral.\n";
      }

      if(strng!=strng2)
            errMsg += "Your passwords do not match!\n";
     
      if(errMsg==''){
            return true;
      } else {
            alert(errMsg);
            return false;
      }
return false;

}
</script>

    <title>Password Reset</title>

</HEAD>

<body>

<FORM NAME="passwordResetForm" ACTION=" " METHOD=post onsubmit="return checkPassword()">


           Enter New Password: <input type=text name=newpass value=""><br>
               Verify Password: <input type=text name=verifypass value=""><br><br>

             <input type=submit value="Reset Password"><br><br><br>

</FORM>
</BODY>
</HTML>
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24112751
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

715 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