SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question comparing user form fields?

    Hi!

    This is my first post to the great Sitepoint.
    I have learned much from here, and now I'm stuck!

    I want to put a form on my site where the user can enter some information, but I don't want the user to enter the same information twice over the couple of fields that I have.

    Is there a javascript that can help to validate the form information or some other way? And if so, is it easy to do?
    I'm sure I saw something about this in a Sitepoint newsletter but I can't find it! Please help!

    Thanks!

  2. #2
    SitePoint Addict w3exit's Avatar
    Join Date
    Jun 2002
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try a search on javascriptkit.com

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here, I made a quick script for you: http://www.rocketweasel.com/examples...wo_fields.html. Try typing the same thing into both fields. Customize the message for your needs.

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this

    PHP Code:
    <script type="text/javascript">
      function 
    checking()
      {
        
    document.forms[0]
        if (
    x.a1.value==x.a2.valuealert('same');
      }
    </script>

    <form id="blah">
      <input type="text" id="a1" />
      <input type="text" id="a2" />
      <input type="button" id="a3" value="check" onclick="checking()"/>
    </form> 

  5. #5
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mine does the same, except that with mine, it doesn't matter which form on the page you're using.

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea i didn't read your post I just wrote it and after I posted it, I read yours lol. I was half asleep at the time.

  7. #7
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Makes sense.

  8. #8
    SitePoint Member
    Join Date
    Jun 2002
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi guys,


    Thanks a million for replying so fast! I even managed to change some of the script to do more fields!
    Your help was very much appreciated, many thanks again!

    ....But one more thing, if I may!

    I want to be able to leave users have fields blank if they don't want to fill them in.

    What it is: I want users to be able to fill in up to 5 email addresses (I'm not bothered if they are invalid) but not have any the same, does this make sense?


    Take care!

    prescience
    Last edited by prescience; Jun 14, 2002 at 02:01.


Bookmarks

Posting Permissions

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