Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts

    Showing X or check, on textboxs

    I have a security code on my website, a user must type it in perfectly according to whats in the database.

    I have 4 text boxes with a max length of 4 characters each. A code would look something like this and is unique.

    e4HQ Dcvz 1P0d Y6Nh

    I would like a red X or a green check image to appear at the end of the box if the code they entered is correct. So it would search the database when all 4 are filled in, and produce if its right or wrong.

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    so have it make it's request to a processor page which will query against wherever you have that code stored and echo what you want depending on the results. you could echo img tags that show the check or X or even change the class of the box element.

    then it's just a matter of deciding when you want that request to go out, be it a onchange on the fields, onblur when clicking something else, a submit\enter button, or even a keystroke capture or something.

  • #3
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Hmm, this could take me weeks to figure out. I just started learning about Ajax yesterday, read 3 pages of a tutorial and am already confused.

  • #4
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    What have you tried. Show us what you have done.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #5
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    I haven't done any Ajax, I only have the PHP part right now.

    Code:
     echo '<form action="rewards.php?do=gamecard" method="post">';
            echo '<input type="text" style=\'background-color:#CDBA96;\' size="4" maxlength="4" name="one" value=""> <input type="text" style=\'background-color:#CDBA96;\' size="4" maxlength="4" name="two" value=""> <input type="text" style=\'background-color:#CDBA96;\' size="4" name="three" maxlength="4" value=""> <input type="text" style=\'background-color:#CDBA96;\' size="4" name="four" maxlength="4" value=""><br><br>';
            echo '<input type="submit" name="code" class="altButtonFormat" value="Process"></form>';
    I don't know Ajax yet, trying to learn it slowly in my free time.

  • #6
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    it's kind of the lazy way, but if you don't have time to learn it in detail you could grab a framework that supports ajax like prototype. if you can read an api doc than you can make as advanced a function as you would ever like.

    http://www.prototypejs.org/

    http://www.prototypejs.org/api/ajax

    you could have it done in a few minutes... but i wouldn't expect to have any great knowledge of ajax afterwards. it really depends what your goal is. if you want to use prototype http://www.prototypejs.org/api/ajax/updater would be more or less what you're looking for. i can show you how to use it if you like.

  • Users who have thanked ohgod for this post:

    masterofollies (09-04-2008)

  • #7
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    ohgod, thank you. I will check that out. Hopefully in a few months, I will know enough to do what I need done.

  • #8
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    no worries. yell if you'd like a hand.

  • #9
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,401
    Thanks
    11
    Thanked 595 Times in 575 Posts
    it would be quite simpler to change the element.backgroundColor to red or green. you will have to use images to display a check, since the unicode value for it is not universally compatible with all fonts and browsers.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%


  •  

    Posting Permissions

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