The following code I'm going to put here works perfectly for input textboxs, but I need it for Calendars/Comboboxs.
So here's an example of what I have so far.
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" /> Finding it..');
this.timer = setTimeout(function () {
$.ajax({
url: 'ex.php',
data: 'action=check&username=' + t.value,
dataType: 'json',
type: 'post',
success: function (j) {
if(j.ok == true){
validateUsername.html(j.msg + "fine!");
}else{
validateUsername.html(j.msg);
}
}
});
}, 200);
this.lastValue = this.value;
}
And, in the PHP code I have:
function check($user){
$user= "Yellow";
$response = array();
$response = array('ok' => true,
'msg' => $user);
return @response;
}
if (@$_REQUEST['action'] == 'check' && isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
echo json_encode(check($_REQUEST['username']));
exit; // only print out the json version of the response
}
Finally, in the html:
<input id="username" name="username" value="<[email protected]$_REQUEST['username']?>"/>
I tried to adapt it to Calendar and it didn't work. Only works if I write by myself the date...if I chose the date from the calendar it doesn't do nothing. With Combobox is the same thing. But in the combobox I'm not able to write, so it does nothing at all.
I thought about the problem could be on the html..so I change the 'Event Value' to 'Event onchange':
<input id="username" name="username" value="<[email protected]$_REQUEST['username']?>"/>
To:
<input id="date" name="date" onchange="<[email protected]$_REQUEST['date']?>"/>
Btw, this last line is from a jQuery MonthCalendar plugin, if necessary I can put here the code.
Any kind of suggestions? Thanks!!
This post has been edited by Keylogger: 17 March 2013 - 07:12 AM

New Topic/Question
Reply



MultiQuote


|