jQuery is not working well
<p>I have one form in which I have an address field where the user can enter many addresses. It's up to the user. They can enter many addresses, it's working fine.</p>

<p>I am checking that the user doesn't enter the same address twice. For this I wrote some jQuery code.</p>

<pre><code>jQuery('#EnrollmentEnrollUserForm').submit(function(){
  // alert(jQuery('#EnrollmentServiceAddress1').val());
  // alert(jQuery('.premise-body').html());
  var add=jQuery('#EnrollmentServiceAddress1').val();
  add=add.toLowerCase();
  var address_string =jQuery('table.premise_details').find('tr:first td:last').html();
  // alert(address_string);
  var address = address_string.split('::');
  address[0]=address[0].toLowerCase();
  // alert(address[0]);
  if(add==address[0]){
  alert("These premises already exist. Please enter other premises.");
    return false;
  }
  // checking whether a premise added is same as the added premises or not
  // var premise_check = true;
  var retval = true;
  jQuery('table.premise_details').each(function() {
    var address_string = jQuery(this).find('tr:first td:last').html();
    // alert(jQuery(this).find('tr:first td:last').html());
    var address = address_string.split('::');
    address[0]=address[0].toLowerCase();
    // alert(address[0]);
    if(add==(address[0])){
      alert("These premises were already added... Please enter other premises.");
      retval = false;
    }
  });
  if(!retval){
    return false;
  }
});
</code></pre>

<p>This code works only sometimes. The problem I am facing is, it's showing an alert if the user enters the same address again, but the page is loading in an infinite loop.</p>

<p>Can anybody tell me what's the problem with that.</p>

<p>Thank you for your help!</p>
