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

  • Home
  • SEARCH
  • 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 8210337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:02:29+00:00 2026-06-07T10:02:29+00:00

I have an ajax driven zip code lookup. The call to the service happens

  • 0

I have an ajax driven zip code lookup. The call to the service happens on keyup after the field has reached the required number of characters (5 for zip). However, if a user continues typing (6+ characters) even though they don’t show in the field, the ajax call is being made and returning with a data is null error:

html

<input type="text" value="" id="billZipCode" name="billZipCode" class="smallInput coreAddrBill" maxlength="5">

javascript

//show city/state on input maxlength
$("input#billZipCode").live("keyup", function( event ){
    if(this.value.length == this.getAttribute('maxlength')) {
        if ($(this).valid() == true ) {
            zipLookup(this, "USA");

        }
    }
});


//zip code lookup
function zipLookup(myField, myCountry) {


    $.ajax({
        type: "POST",
        url: postalCodeLookupURL,
        dataType:"text json",
        data: { postalcode: $(myField).val(), country: myCountry },
        success: function(data) {
            var isError = data.isError;
            var city = data.city;
            var juris = data.juris;
            if(isError == "false"){

                    $(myField).parent().next('div').find('input').val(city);
                    $(myField).parent().next('div').next('div').find("select option[value='" + juris +"']").attr('selected', 'selected');
                    $("#createAccount").validate().element($(myField).parent().next('div').find('input'));
                    $("#createAccount").validate().element($(myField).parent().next('div').next('div').find("select"));

            }


        },
        error: function(){
        alert('failure');
      }

     });


}
  • 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-07T10:02:31+00:00Added an answer on June 7, 2026 at 10:02 am
    //Live is depreciated,use delegate and some other tweaks
        $("body").delegate("input#billZipCode","keyup", function( event ){
            if($(this).val().length >= $(this).attr('maxlength')) {          
                    zipLookup(this, "USA");
    
            }else{
             alert('Max reached');
          }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have ajax code for asp.net (non-mvc) to call to a webMethod to get
If I have a rich AJAX-driven GUI in ASP.NET MVC, how would I unit
I have a problem consistently displaying Facebook Comments on my AJAX driven website. Each
I have multiple ajax requests with javascript code as response, and I need to
I have a primarily Ajax-driven site, the content of which is populated by making
I've created an ajax driven flot line chart that I would like to have
I have a JAX-WS-driven web service whose WSDL we generate a web service client
In a ajax-driven site I have added some default data using the ajaxSetup, ala
I have an admin that is almost completely ajax driven. When the page loads
I have an HTML page with a JavaScript code that sends AJAX request. The

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.