Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2009, 04:37 PM   PM User | #1
ashton321
New to the CF scene

 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ashton321 is an unknown quantity at this point
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!
ashton321 is offline   Reply With Quote
Old 11-25-2009, 06:58 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You may be interested in the Validate plugin:

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

Dead simple to use.
__________________
Fumigator is offline   Reply With Quote
Old 12-08-2009, 10:51 AM   PM User | #3
avanoah2
New to the CF scene

 
Join Date: Dec 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
avanoah2 is an unknown quantity at this point
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?
avanoah2 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 04:53 PM.


Advertisement
Log in to turn off these ads.