SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
Thread: Comparing Two Password Strings
Hybrid View
-
Aug 21, 2003, 03:19 #1
- Join Date
- Jul 1999
- Location
- Lancashire, UK
- Posts
- 8,277
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Comparing Two Password Strings
I have not done any programming in years adn someone asked me this today:
"I wanna compare two password strings.
I don't think I can use
IF (pass1 == pass2) equal to
because they are not numerical I certainly cant use
IF (pass1 <> pass2) not equal to
so how do I check that pass1 is the same as pass2."
-
Aug 21, 2003, 03:24 #2
- Join Date
- Nov 2000
- Location
- Chico, Ca
- Posts
- 1,125
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What lanaguage are you refering to?
"Happiness doesn't find you, you find happiness" -- Unknown
www.chuckknows.com
-
Aug 21, 2003, 03:25 #3
-
Aug 21, 2003, 03:28 #4
- Join Date
- Nov 2000
- Location
- Chico, Ca
- Posts
- 1,125
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
opps didn't notice it was in the Javascipt forum
If it was .net I could help ya.."Happiness doesn't find you, you find happiness" -- Unknown
www.chuckknows.com
-
Aug 21, 2003, 07:07 #5
- Join Date
- Jul 2003
- Location
- Sacramento, CA
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Nicky The first one is correct!
Code:var myString="hello" if("hello"==myString){ staments to execute if true! } else{ statments to execute if false! }
-
Aug 21, 2003, 07:12 #6
- Join Date
- Jul 2003
- Location
- Sacramento, CA
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sorry I didnt completly read your post! It should compare them both the same if its a string, number, or boolean!
Code:var myString=parseInt(20,10); if(20==myString){ staments to execute if true! } else{ statments to execute if false! }
Code:var myString=true; if(true==myString){ staments to execute if true! } else{ statments to execute if false! }
-
Aug 21, 2003, 12:51 #7
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
As poop_shoot implies, comparision is virtually the same regardless of primitive type. So,
Code:if (pass1 == pass2)
poop_shoot:
Code:var isOK = true; if(isOK) { statements to execute if true! } else { statements to execute if false! }
Code:var isOK = false; if (! isOK) { statements for false condition }
Where the World Once Stood
the blades of grass
cut me still
-
Aug 21, 2003, 16:52 #8
- Join Date
- Jul 2003
- Location
- Sacramento, CA
- Posts
- 330
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks vinny I posted that kind of hastly! Thanx 4 pointing out what I missed!
-
Aug 21, 2003, 20:09 #9
- Join Date
- Mar 2002
- Location
- Lappeenranta, Finland
- Posts
- 176
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Nikcy D
like they said,
if (pass1 == pass2) {}
is correct.
if you want to see if passwords are not the same, use
if (pass1 != pass2) {}
this works with numbers, strings, etc.
var pass1 = "test";
var pass2 = "test";
if(pass1 == pass2){
alert("ok");
}else{
alert("not ok");
}
Bookmarks