jeudi 26 janvier 2017

if Checkbox is checked or input:text has value

I have a function, which should check if input:text has value or if checkbox is checked. if not then popup appeares. It works only with checked/unchecked input, and not with input:text. What am I doing wrong here:

$("#wcv-product-edit #save_button").click(function(){
var checked = $("#shipping input:checked" ).length > 0;
var text_value = $("#shipping input:text" ).length > 0;
var store_checked = $("#store_shipping input:checked").length > 0;
if (!checked && !store_checked || !text_value && !store_checked){
    $('#ship_wrong_popup').show();
    $('.page .wcv-tabs .tabs-nav li a.shipping').addClass('ship_highlight');
    return false;
} else if (!checked && store_checked || !text_value && store_checked){
    // $('#ship_wrong_popup').show();  
    return true;
} else if (checked && store_checked || text_value && store_checked){
    // $('#ship_wrong_popup').show();  
    return true;
}

});




Aucun commentaire:

Enregistrer un commentaire