You have an infinite submit loop, and then preventing your form from submitting when the value of the cat_id
text field cat_id
not 0. Remove the else
block as it does not serve the actual purpose.
More details:
function teamValidation(){ var cat_id = $('#cat_id').val(); if(cat_id == "0"){ alert("Category is invalid..."); return false; }else{ $('#addForm').submit(); // this submits the form again - does NOT proceed with this submission of the form return false; // returning false will prevent the submission from being completed } } <form action="<?php echo SITE_URL; ?>adminteams/saveDetail/" name="addForm" id="addForm" onsubmit="return teamValidation();"> <input type="hidden" name="cat_id" id="cat_id" value="1"/> </form>
When submitting a form, teamValidation()
called. If the check teamValidation()
else
block code is executed), you submit the form again , which calls teamValidation()
again , then return false
, which will prevent this current teamValidation()
from ending, Firefox probably fails, because it is in a loop where it constantly submits a form that is never allowed to complete; the fact that the browser is pretty awful in terms of memory usage probably doesn't help either.
source share