Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7999007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:22:32+00:00 2026-06-04T15:22:32+00:00

I have one form in which I have an address field where the user

  • 0

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.

I am checking that the user doesn’t enter the same address twice. For this I wrote some jQuery 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;
  }
});

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.

Can anybody tell me what’s the problem with that.

Thank you for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:22:34+00:00Added an answer on June 4, 2026 at 3:22 pm
    jQuery('#EnrollmentEnrollUserForm').submit(function(){
      var add=jQuery('#EnrollmentServiceAddress1').val();
    
      add=add.toLowerCase();
    
      var address_string =jQuery('table.premise_details').find('tr:first td:last').html();
    
      var address = address_string.split('::');
    
      address[0]=address[0].toLowerCase();
    
      if(add==address[0]){
    
      alert("These premises already exist. Please enter other premises.");
    
        return false;
    
      }
    
      jQuery('table.premise_details').each(function() {
    
        var address_string = jQuery(this).find('tr:first td:last').html();
    
        var address = address_string.split('::');
    
        address[0]=address[0].toLowerCase();
    
        if(add==(address[0])){
    
          alert("These premises were already added... Please enter other premises.");
    
        return false;
    
        }
    
      });
    
    });
    

    The reason why you are getting issue is you have call checking your retval after you are finishing you loop of each function, show its taking last set value of retval and creating issue for you, here i have change code and returning false as i match my condtion .
    I have edited code.. please check this code

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How I can combine multiple form elements to one validator? I have address information
i have one signup form where i have three field username,password and email address
i have one form which have some input box and some select box. i
in my project i have one registration form which is developed in C#.net.to this
I have created one jsp form which contains the username textfield. On the click
I need to make the program which have one form that contains PNG image
I am creating one form in html using table. Which have one Drop down
I have written a simple CRUD form which has one select list. However the
I have one combobox on the window form and I have one method which
I have a form that collects information, one piece of which is a phone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.