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 7521607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:16:37+00:00 2026-05-30T02:16:37+00:00

I am using the following Ajax code on a PHP page to check to

  • 0

I am using the following Ajax code on a PHP page to check to see if a sales tax field is populated. The sales tax field is populated only when a valid zip code is entered. How do I change the css style back once it has been flagged as missing the value?

var xmlhttp;


function showUser(str) {

    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null) {
        alert ("Browser does not support HTTP Request");
        return;
    }
    var url="response.php";
    url=url+"?q="+str;
    url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function stateChanged() {
    if (xmlhttp.readyState==4) {
        document.getElementById("result").value=xmlhttp.responseText;
        if(document.getElementById("result").value =='') {
            validateZip();
        }
    }
}

function GetXmlHttpObject() {
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject) {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}

function validateZip() {
    if(document.newagreementform.tax.value=="") {
        alert("A valid zip code in our service area is required.");
        document.newagreementform.zipcode.focus();
        document.newagreementform.zipcode.style.backgroundColor="#ffff99";
        document.newagreementform.zipcode.style.borderColor="#990000";      
        return false;
    }
    if(document.newagreementform.tax.value!=""){document.newagreementform.zipcode.style.backgroundColor="#ffffff";} 
}
  • 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-05-30T02:16:39+00:00Added an answer on May 30, 2026 at 2:16 am

    How about putting an event on the input field for the zip code… something like:

    <input Id="Zip" onkeypress="RemoveZipCodeErrorMessage()">
    

    then your RemoveZipCodeErrorMessage() function would look something like:

    function RemoveZipCodeErrorMessage()
    {
    // change to color you want to return to
    document.newagreementform.zipcode.style.backgroundColor="#ffff99";                          
    document.newagreementform.zipcode.style.borderColor="#990000"; 
    }
    

    Andrew

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

Sidebar

Related Questions

I am successfully posting a form via ajax, using the following code; $.post( Page.do?source=ajax,
I am using jQuery and Ajax, and my Ajax.php file returns the following field
Doing an ajax get request works as expected using the following code: $.ajax({ type:
I'm using the following piece of code to login a user via Ajax. //Capture
I am trying to perform a nested AJAX call using the following code. The
I am using jQuery and Ajax. My MainFile has the following code: <html> <head>
I am using the following html page: <html> <head> <title>AJAX Example</title> <meta http-equiv=Content-Type content=text/html;
I am using the following code. Which is submitting fine with php and it
I can not figure out why the following AJAX code will only load the
I am using php/ajax to submit a form without page refresh. Here are my

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.