Having Issue on Validating Sub Validation (Nested If)
Can you please take a look at
This Demo and let me know why I am not able to validate the query properly? As you can see I have 3 groups of selections and in the top level of validation I am able to validate the `isValidQuery` but int the `
Selection Group #3 ` where user has options to select `
Not Sure ` or `
Luxury ` or `
Economics ` WHERE the the `#
selected-luxury-Items ` must be validate if the `
Luxury ` been selected or `
#selected-econo-Items ` must be validate if the `
Economics ` has been selected I am not doing things correct!
- function validateRequst() {
- var selectedtGroup1 = $("#selectedCar").val();
- var selectedtGroup2 = $("input:checkbox[name=opts1]").val();
- var selectedtGroup3 = $("input:radio[name=opts2]").val();
- if (selectedtGroup1 == 0 && ($(selectedtGroup2).is(':checked') == false) && ($(selectedtGroup3).is(':checked') == false)) {
- $("#error").slideDown();
- isValidQuery = false;
- }
- //Hee is the parst has Problem
- if ($(selectedtGroup3).is(':checked') == false) {
- var selectedLuxuary = $("#selected-luxury-Items").val();
- var selectedEconomics = $("#selected-econo-Items").val();
- if ($(selectedtGroup3).val() == "luxury") {
- if (selectedLuxuary == 0) {
- isValidQuery = false;
- $("#error").slideDown();
- }
- }
- if ($(selectedtGroup3).val() == "economics") {
-
- if (selectedEconomics == 0) {
- $("#error").slideDown();
- isValidQuery = false;
- }
- }
-
- } else {
- isValidQuery = true;
- }
- }
Thanks