Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2002
    Posts
    14

    Unanswered: 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

  2. #2
    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

  3. #3
    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

  4. #4
    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

  5. #5
    Join Date
    Jun 2002
    Posts
    14
    I sent you a private message with a link to the code. Thx

    ~AbM

  6. #6
    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 Attached Files
    My homepage:
    http://www.buro9.com/
    My work:
    http://www.btopenworld.com/
    http://www.officialfootballsites.co.uk/
    http://www.jeepster.co.uk/

  7. #7
    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 20:06.

  8. #8
    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/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •