I have 2 input box. Each with ID abc and xyz. The ajax function is activate when any of the 2 box out of focus and check if the other box is empty. If both input box have value, it will pass the info to tmp.php to process and shall return some value.
I have written the code. But like to know is there possible to shorten the script? The method I am using is actally repeat of different input box.
<input id = abc>
<input id = zyx>
$("#abc)
.blur(function(){
if ($("#zyx).val() !=''){
$.ajax({
url: tmp.php,
dataType: "json",
data: {
value : zyx
},
success: function(data){
alert ("OK");
} }
});
}
});
$("#zyx)
.blur(function(){
if ($("#abc).val() !=''){
$.ajax({
url: tmp.php,
dataType: "json",
data: {
value : zyx
},
success: function(data){
alert ("OK");
} }
});
}
});
you could write