If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Comparing Request Object items with javascript

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-02, 20:01
AbsolutMauser AbsolutMauser is offline
Registered User
 
Join Date: Jun 2002
Posts: 14
Comparing Request Object items with javascript

Greetings,

I am trying to determine if two submitted passwords are equal. So, I have a litte "if" line like so:

if(Request.Form("password") != Request.Form("verifypassword"){
return false;
}

However, no matter what is in the password and verifypassword fields, it always returns false, even if they are the same! (verified by using an =Request.Form("password") and =Request.Form("verifypassword") in the HTML doc to check the values outside of the password field. I have also tried creating string objects called pass1 and pass2, saving the two Request.Form items to them, and then comparing them as pass1.toString() and pass2.toString() again to no avail. Anyone have any thoughts as to what is going on in my app? Thanks!

~AbM
Reply With Quote
  #2 (permalink)  
Old 07-08-02, 08:12
buro9 buro9 is offline
Member
 
Join Date: Aug 2001
Location: London, UK
Posts: 31
you're 'not equals' is wrong if you're in asp... try <>

e.g.

if (Request.Form("password") <> Request.Form("verifypassword") {
return false;
}


if you're in javascript, then this should be part of the onsubmit() for the form, and could be written like:

var form = document.forms["yourFormName"];
if (form.password1.value != form.password2.value) {
return false;
}

cheers

david k
Reply With Quote
  #3 (permalink)  
Old 07-08-02, 11:30
AbsolutMauser AbsolutMauser is offline
Registered User
 
Join Date: Jun 2002
Posts: 14
I get errors when I use <>. I am using javascript in ASP, not VBScript. I have now tried a construction where I use == to determine if the two are equal instead of determining if they are unequal, however, this also fails every time. I can't figure this out!

~AbM
Reply With Quote
  #4 (permalink)  
Old 07-08-02, 12:05
buro9 buro9 is offline
Member
 
Join Date: Aug 2001
Location: London, UK
Posts: 31
can you mail me the whole of that HTML page, i'll go through it and mail back the solution.

cheers

david k
Reply With Quote
  #5 (permalink)  
Old 07-08-02, 12:25
AbsolutMauser AbsolutMauser is offline
Registered User
 
Join Date: Jun 2002
Posts: 14
I sent you a private message with a link to the code. Thx

~AbM
Reply With Quote
  #6 (permalink)  
Old 07-08-02, 15:51
buro9 buro9 is offline
Member
 
Join Date: Aug 2001
Location: London, UK
Posts: 31
Attached file shows basic javascript validation, I tested it and it works fine.

As I said in the PM, I was surprised to see you code ASP pages using JScript and thought that you were actually trying to do it client side. You may need to check what JScript documentation there is for a server side solution... alternately switch to VB or C# and I'll be able to help

Anyhow, attached file should solve part of it for you.
Attached Files
File Type: txt passwordcompare.txt (1.2 KB, 1514 views)
__________________
My homepage:
http://www.buro9.com/
My work:
http://www.btopenworld.com/
http://www.officialfootballsites.co.uk/
http://www.jeepster.co.uk/
Reply With Quote
  #7 (permalink)  
Old 07-08-02, 19:02
AbsolutMauser AbsolutMauser is offline
Registered User
 
Join Date: Jun 2002
Posts: 14
Thanks! I also found that using the String() function around Request objects works as well and solved another problem I was having. Apparently, Request objects do not actually return strings, they return some other nebulous form of data just like in (duh) other object oriented applications. When comparing two objects, even if they carry the same value, the will not necessarily evaluate as equals. I was attempting to define new string objects using "new String()" and then the .toString() method to compare them (this failed). I was not aware that simply enclosing an object in String() would cause it to be evaluated as a string. Nonetheless, all is happy again. Thanks for your help!

~AbM

Last edited by AbsolutMauser; 07-08-02 at 19:06.
Reply With Quote
  #8 (permalink)  
Old 07-09-02, 02:04
buro9 buro9 is offline
Member
 
Join Date: Aug 2001
Location: London, UK
Posts: 31
Ah yes! Of course, in C# I've just spent the last few days mostly typing .ToString() at the end of everything... sure I was building an app, but god you get bored of typing that!
__________________
My homepage:
http://www.buro9.com/
My work:
http://www.btopenworld.com/
http://www.officialfootballsites.co.uk/
http://www.jeepster.co.uk/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On