javascript - Compare and validate input fields -


this question has answer here:

i need compare , validate 4 fields in following manner:

if writes client number in field, there no need fill address fields. likewise if fills address fields won't have fill in client number.

here code:

$('#form1').submit(function(event) {     if ($(this).find('#address, #city, #postalcode, #customernum [input]').val() == '') {         alert('please enter client number or address!')     }     event.preventdefault(); } 

$('#form1').submit(function(event) {     var formok = false;     if ($("#customernum").val() != "") {            formok = true;     } else {        formok = true;        $("#address, #city, #postalcode").each(function () {            if ($(this).val() == '') {                formok = false;                return false; // break out of loop            }        });     }     if (!formok) {        alert('please enter client number or address!')        event.preventdefault();     } }  

Comments