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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with form validation

    Hi,

    I have set up all my fields to validate with php and ajax using the jquery library.

    The php array returned is
    $response = array(
    'ok' => true or false,
    'msg' => "message about ok or why failed"
    );

    The is correctly printed next to the corresponding input box. Now i would to check to make sure that they all returned ok = true when the form is submitted. However i am new to javacript and ajax and dont know where to begin.

    javascript function
    Code:
    var validateUsername = $('#validateUsername');
      $('#username').keyup(function () {
        var t = this; 
        if (this.value != this.lastValue) {
          if (this.timer) clearTimeout(this.timer);
          validateUsername.removeClass('error').html('<img src="../images/ajax-loader.gif" height="16" width="16" /> checking username availability...');
          
          this.timer = setTimeout(function () {
            $.ajax({
              url: '../scripts/validatefunctions.php',
              data: 'action=check_username&username=' + t.value,
              dataType: 'json',
              type: 'post',
              success: function (j) {
                validateUsername.html(j.msg);
              }
            });
          }, 200);
          
          this.lastValue = this.value;
        }
      });
    html
    Code:
    <div>
                                                    <label for="username">Username, valid: a-z.-_</label>
                                                    <input type="text" name="username" value="" id="username" />
                                                    <span id="validateUsername"></span>
                                            </div>
    Thanks!

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You may be interested in the Validate plugin:

    http://plugins.jquery.com/project/validate

    Dead simple to use.

  • #3
    New to the CF scene
    Join Date
    Dec 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    comment

    I have got many certificates and cleared many exams such as vmware certification and as well as the pmp certification at the last but not least the most important one the oracle certification but unable to understand the real concept of php and the exe files.Would you like to clear it for me?


  •  

    Posting Permissions

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