How to Check null value in jquery
Are you looking for a way to Check null value in jquery then read this thread to know how to check it
Hi, i want to check any null value in textbox using jquery.
in my application, want to check nearly 20 text boxes.
this is my code. a function for checking null value
function checking() {
var empty = 0;
$('input[type=text]').each(function () {
if (this.value == "") {
empty++;
return false;
}
})
}
following is code for inserting
$('#ainsert').click(function (e) {//a1insert
e.preventDefault();
);
var vtype = $('#txtvtype').val();
var vloc = $('#txtlocation').val();
var vchrid = $('#txtvoucherid').val();
var vdate = $('#txtvoucherdate').val();
var vamt = $('#txtcash').val();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "CashPaymentVoucher2.aspx/InsertVoucher",
data: "{Vtype:'" + vtype + "',Vloc:'" + vloc + "',Vdate:'" + vdate + "',Vaccount:'" + vamt + "'}",
dataType: "json",
success: function (data) {
alert(data.d);
},
error: function (xhr) {
alert(xhr.responseText);
}
});
});
My requirement is if any textbox is null .insert button should'nt fired and empty text box's background clor should be red.
How it is possible.
Regards
Baiju