Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 21st, 2006, 12:10 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Here's a regular expression test for password in javascript that will work well in classic ASP.

//Password validation
    if(form.EmpPass.value==0)
    {
        alert("Password is missing.");
        form.EmpPass.focus();
        return false;
    }
    var errorCounter = 0;
    var errorMsg = "";
    var space = " " ;
    var fieldname = form.EmpPass;
    var fieldvalue = fieldname.value;
    var fieldlength = fieldvalue.length;

    if (!(fieldvalue.match(/\W+/)))
    {
         errorMsg += "\nPasswords must include at least one special character - #,@,%,!\n";
          errorCounter += 1
    }
    if (!(fieldvalue.match(/\d/)))
    {
         errorMsg += "\nPasswords must include at least one number.\n";
          errorCounter += 1
    }
    if (!(fieldvalue.match(/[a-z]/)))
    {
         errorMsg += "\nPasswords must include one or more lowercase letters.\n";
    }
    if (!(fieldlength >= 7))
    {
         errorMsg += "\nPasswords must be at least 7 characters long.\n";
          errorCounter += 1
    }
    if (fieldvalue.indexOf(space) > -1)
    {
         errorMsg += "\nPasswords cannot include a space.\n";
          errorCounter += 1
    }
    if (errorMsg != "")
    {
        if(errorCounter > 1)
        {
        msg = "Please correct the problems with your password.\n";
        msg += "_________________________________________________ _____\n";
        }
        else
        {
        msg = "Please correct the problem with your password.\n";
        msg += "_________________________________________________ _____\n";
        }
    errorMsg += alert(msg + errorMsg + "\n\n");
    fieldname.focus();
    return false;
    }
    //End of password validation.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Array Question interrupt Javascript How-To 1 November 2nd, 2005 07:34 AM
Question on the ARRAY function savoym VBScript 6 May 31st, 2005 06:53 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.