Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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 October 7th, 2003, 11:10 AM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Default battling to add username & password too similar...

hi all,

i'm sitting with a huge problem which has been bugging me for the past week.
the outside if below always returns true even if in reality it is false o_O

Code:
// Start script section

if (username.substring(0,4).toUpperCase == password[0].substring(0,4).toUpperCase) {
    if (!confirm('Username and password are too similar.\nThis is not advised... Continue?')) {
        return false;
    }
}

// End script section
any swift help would be greatly appreciated,

Sincerely,
Pierre du Toit.
__________________
Sincerely,
Pierre "Greywacke" du Toit
[email protected]
don't worry about my 0 thankyou's either way, i would say thank you should you help, and i will gladly help others when this work rush is over.
 
Old October 7th, 2003, 11:26 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Because there are no parentheses at the end of your expressions you are comparing functions not their results, try:
Code:
username.substring(0,4).toUpperCase() == password[0].substring(0,4).toUpperCase()

--

Joe
 
Old October 7th, 2003, 12:07 PM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Default

well, gonna test that now... but i always thought toUpperCase was a string property, not a function... thx for the help tho

Sincerely,
Pierre du Toit.
 
Old October 7th, 2003, 12:11 PM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Default

yep it worked ;) thx a mill man...

Sincerely,
Pierre du Toit.
 
Old October 8th, 2003, 02:23 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you'd followed one of the first rules of debugging, check your data, and alerted one of the values you'd have spotted it right away, compare:
Code:
alert(username.substring(0,4).toUpperCase);
to
Code:
alert(username.substring(0,4).toUpperCase());

--

Joe





Similar Threads
Thread Thread Starter Forum Replies Last Post
Memorise ODBC Username & Password in Access DB Roly Reefer Access VBA 23 January 20th, 2012 02:32 AM
Regarding Username and password kuku_ashu Javascript How-To 0 January 4th, 2008 11:28 AM
username and password abhi_loveu2002 ASP.NET 2.0 Basics 1 December 14th, 2006 05:25 AM
Username and password Hennie Access 1 July 28th, 2006 12:43 AM
Username & Password Hennie Access VBA 2 July 25th, 2006 12:33 AM





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