Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
| Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics 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 May 22nd, 2007, 07:54 AM
Authorized User
 
Join Date: Jan 2004
Location: Manchester, , United Kingdom.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Ashleek007
Default validation problem

hi all,

I'm working on validating a username and password.... heres what I have so far.... i know the validation falls down when im trying to check the format of the password...

Code:
function fnValidate(jsValidationType, Action, type, page, db)
{
  switch(jsValidationType)
  {
   var re = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/;

    case 'Account': if (document.REG_FORM.USER_NAME.value.length < 6)
                {
                    alert ("Please enter username at least 6 characters in length");
                    //document.REG_FORM.USER_NAME.style.borderStyle = "dotted";
            //document.REG_FORM.USER_NAME.style.borderColor = "red";
            document.REG_FORM.USER_NAME.focus();
                    return false;
                }

#####falls down here i think#################

                if (document.REG_FORM.USER_NAME.value != re)
                {
                    alert ("The username you have entered does not follow the correct format - for security reasons, this must be at least 6 characters in length, containing letters (upper & lowercase) plus one or more numbers and/or symbols, e.g. ‘Usern@me’ or ‘Username1’");
                    //document.REG_FORM.USER_NAME.style.borderStyle = "dotted";
            //document.REG_FORM.USER_NAME.style.borderColor = "red";
            document.REG_FORM.USER_NAME.focus();
                    return false;
                }

#########################################################

                if (document.REG_FORM.PASSWORD.value.length < 6)
                {
                    alert ("Please enter password at least 6 characters in length");
                    document.REG_FORM.PASSWORD.focus();
                    return false;

                }
                if (document.REG_FORM.PASSWORD.value != document.REG_FORM.PASSWORD_CHECK.value)
            {
            alert ("The password you entered does not match your first entry. Please try again");
            document.REG_FORM.PASSWORD_CHECK.value = "";
            document.REG_FORM.PASSWORD.value = "";
            document.REG_FORM.PASSWORD.focus();

            return false;
            }

            fnFireCREvent(Action, type, page, db);

                break;


   }    
}
Hope someone can help....

Cheers,

My new web design domain
www.askmultimedia.co.uk
__________________
My new web design domain
www.askmultimedia.co.uk
 
Old June 18th, 2007, 01:16 AM
Authorized User
 
Join Date: Jun 2007
Location: Tehran, Tehran, Iran.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Note that this question relates to Javascript not Java and you should post it to Javascript forum not here.

Anyway,

You can not compare string to regular expressions in this way. You could use 'match' method of 'String' object of javascript. It takes a regular expression object as a parameter, compare itself with given pattern and returns an array containing result of comparison.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation problem monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 November 25th, 2006 01:44 PM
Interesting validation problem jacob ASP.NET 1.0 and 1.1 Professional 5 February 16th, 2006 07:16 PM
Validation and Insert problem addos Beginning PHP 0 January 17th, 2005 06:50 PM
validation problem Abhinav_jain_mca General .NET 6 August 5th, 2004 02:32 PM





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