jeudi 24 novembre 2016

jQuery : If condition working but how to check result in all the if conditions

My problem is in this part of the code. I need both of these conditions to be checked for different cases.

       if(!printnameoptionfucntions.printnameValidation()){
            return false;
        }
        else if(!optionfucntions.engravingValidation()){
            return false;
        }

It only check the first condition always. I have also tried like this

      if(!printnameoptionfucntions.printnameValidation()){
            return false;
        }

         if(!optionfucntions.engravingValidation()){
            return false;
        }

This is the code for #button-add click

  $('#button-add').on('click', function() {
    //.product-info select
    //ajax_price();

    if($(".engravingDropDown option:selected").attr('data-engraving') == 'No Engraving') {
        $('#myModal').modal('hide');
    }
    /* change button text depend on options selection */
    if($('#myOptions').is(':has(span)') === true){

        $('#select-options').text('REVIEW OR EDIT OPTIONS AND ACCESSORIES');


    }else{

        $('#select-options').text('SELECT AVAILABLE OPTIONS AND ACCESSORIES');
    }
    <?php if($showCustomizeBook){ ?>
    $('#customizeBookCustomPriceText').show();
    <?php } ?>
    if(!printnameoptionfucntions.printnameValidation()){
        return false;
    }
    else if(!optionfucntions.engravingValidation()){
        return false;
    }
    checkDropdownToSetButtonvalue();
    $('.selectMandatoryOption').hide().text('');
});

Aucun commentaire:

Enregistrer un commentaire