Results 1 to 2 of 2

Thread: JavaScript for Password Validity Tester

  1. #1
    HernandezOrtiz is offline Senior Member
    Join Date
    Dec 2009
    Posts
    301
    Rep Power
    3

    Default JavaScript for Password Validity Tester

    Hi. I am website developer. I am working on one live project where I use PHP as a frontend and mySQL as a backend also I use JavaScript for validation. In my login password field is there for that I want to write JavaScript for Password Validity Tester to check user password strength. I tried various course but none of them worked out me. If anybody has suitable code then let me know that.

  2. #2
    Davismoore is offline Senior Member
    Join Date
    Dec 2009
    Posts
    284
    Rep Power
    3

    Default

    Try the script which is given below which may solve your problem:

    Code:
    <script language="JavaScript">
    var errorMsg = "";
    var space  = " ";
    fieldname   = document.myform.password; 
    fieldvalue  = fieldname.value; 
    fieldlength = fieldvalue.length; 
    
    if (fieldvalue.indexOf(space) > -1) {
         errorMsg += "nPasswords cannot include a space.n";
    }     
    if (!(fieldvalue.match(/d/))) {
         errorMsg += "nStrong passwords must include at least one number.n";
    }
    if (!(fieldvalue.match(/^[a-zA-Z]+/))) {
         errorMsg += "nStrong passwords must start with at least one letter.n";
    }
    if (!(fieldvalue.match(/[A-Z]/))) {
         errorMsg += "nStrong passwords must include at least one uppercase letter.n";
    }
    if (!(fieldvalue.match(/[a-z]/))) {
         errorMsg += "nStrong passwords must include one or more lowercase letters.n";
    }
    if (!(fieldvalue.match(/W+/))) {
         errorMsg += "nStrong passwords must include at least one special character - #,@,%,!n";
    }
    if (!(fieldlength >= 7)) {
         errorMsg += "nStrong passwords must be at least 7 characters long.n";
    }
         if (errorMsg != ""){
              msg = "______________________________________________________nn";
              msg += "test.n";
              msg += "______________________________________________________n";
              errorMsg += alert(msg + errorMsg + "nn");
              fieldname.focus();
              return false;
         }
         
         return true;
    }
    
    </script>
    I have tried the given script but it didn’t solve my problem. Please try to provide some other solution.

Similar Threads

  1. Javascript Password security
    By RussellBarnes in forum Programming
    Replies: 0
    Last Post: 08-06-2010, 02:52 PM
  2. Microsoft Suspected spy as a software tester
    By david martin in forum Latest Hardware News
    Replies: 0
    Last Post: 07-15-2010, 08:00 AM
  3. Replies: 0
    Last Post: 06-09-2010, 11:58 AM
  4. JavaScript for username and password
    By ThomasBarnes in forum Programming
    Replies: 1
    Last Post: 04-28-2010, 01:58 PM
  5. METRA Digital insulation resistance tester
    By undirwok in forum Everything Else
    Replies: 0
    Last Post: 10-17-2008, 07:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48