...

View Full Version : jQuery Help with form validation



ashton321
11-25-2009, 05:37 PM
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

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

<div>
<label for="username">Username, valid: a-z.-_</label>
<input type="text" name="username" value="" id="username" />
<span id="validateUsername"></span>
</div>


Thanks!

Fumigator
11-25-2009, 07:58 PM
You may be interested in the Validate plugin:

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

Dead simple to use.

avanoah2
12-08-2009, 11:51 AM
I have got many certificates and cleared many exams such as vmware certification (http://www.real-testking.com/vendor/VMware.htm) and as well as the pmp certification (http://www.real-testking.com/vendor/PMI.htm) at the last but not least the most important one the oracle certification (http://www.real-testking.com/vendor/Oracle.htm) but unable to understand the real concept of php and the exe files.Would you like to clear it for me?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum