I have a jquery to trigger submit button but out of 4 ifs, only two are working properly the other two are not. I was looking for error for some hours but I don't see it. bool1 and 3 works, 2 and 4 doesn't
$("#btnSubmitNM").click(function () {
var msg = "";
if (smLocation.lenght > 3 && smActivity.lenght > 3 && smDescription.lenght > 3) {
//bool 1
if (($("#Equip").prop('checked') == true) && ($("#PTW").prop('checked') == true)) {
if (equipText.lenght > 3 && ptwText.lenght > 3) {
$('#NMNew').submit();
}
else {
msg = msg + "All fields have to be filled";
}
}
//bool 2
else if (($("#Equip").prop('checked') == true) && ($("#PTW").prop('checked') == false)) {
if (equipText.lenght > 3) {
$('#NMNew').submit();
}
else {
msg = msg + "All fields have to be filled";
}
}
//bool 3
else if (($("#Equip").prop('checked') == false) && ($("#PTW").prop('checked') == true)) {
if (ptwText.lenght > 3) {
$('#NMNew').submit();
}
else {
msg = msg + "All fields have to be filled";
}
}
//bool 4
else if (($("#Equip").prop('checked') == false) && ($("#PTW").prop('checked') == false)) {
$('#NMNew').submit();
}
}
else {
msg = msg + "All fields have to be filled";
}
$("#msg").text(msg);
});
and html

Sachin SinghPosted Jun 17, 2021, 7:39 AM
Marius VasilePosted Jun 16, 2021, 9:53 AM
Sachin SinghPosted Jun 16, 2021, 9:46 AM
Marius VasilePosted Jun 16, 2021, 9:42 AM
Marius VasilePosted Jun 16, 2021, 9:41 AM
Thank you Sachin, so, I have 4 situation, A and B checkboxes, both checked, both not checked, A checked B unchecked and A unchecked B checked. If a checkbox is checked I want to make sure the associated texbox is filled
Salman BegPosted Jun 16, 2021, 8:17 AM
Sachin SinghPosted Jun 16, 2021, 8:10 AM