Crea tu propia función jQuery
Con jQuery.fn podras declarar funciones que se pueden usar al igual que las funciones de jQuery normales, en los elementos DOM!.
[js]
jQuery.fn.extend({
ITValidaParte1: function () {
var valor = $(this).val();
var ret = true;
this.each(function () {
$.ajax({
url: ‘Man_Ajax.asp’,
type: ‘POST’,
data: ‘NP=’ + valor + ‘&opcion=chkParte’,
async: false,
beforeSend: function () { },
success: function (response) {
if (response === ‘1’) {
ret = true;
} else {
ret = false;
}
},
complete: function () {
}
});
});
return ret;
}
});
[/js]
Se utilizaría así:
[js]
if ( !$(‘#Parte’).ITValidaParte1() ) {
alert(‘Número No existe’);
}else{
alert(‘Número Existe’);
}
[/js]