use .each instead of foreach loop. <script> $(".form-box").submit(function(){ var allhasvalue = false; var namehasvalue = false; var pricehasvalue = false; $('[name="title[]"]').each(function(){ if ($.trim($(this).val()).length > 0){ namehasvalue = true; } }); $('[name="price[]"]').each(function(){ if ($.trim($(this).val()).length > 0){ pricehasvalue = true; } }); if (!namehasvalue) alert("Please fill Product Name"); if (!pricehasvalue) alert("Please fill Product Price"); if(namehasvalue == false || pricehasvalue == false) { allhasvalue = false; } return allhasvalue; }); </script>
Enter your email address:
Subscribe in a reader
If you feel my website is informative and it is useful for you, please donate some money to support me or buy me a drink. I will continues this good works. Thank you.
0 comments