Subject: Ajax change textbox bgcolor after Criteria met
Posted By: mkthompson Post Date: 7/23/2008 6:15:16 AM
I have created this script:

<script type="text/javascript">
function showHint(str)
{
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="Scripts/ASP/CheckNewUsername.asp";
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("InputSource").style.backgroundcolor='red';
VarResult = xmlHttp.responseText;
document.getElementById("txtHint").innerHTML=VarResult;
 }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
  </script>

---------


The script goes to an asp page checks a database to see if the email address entered into a text box is correct and then the java displays a message. This works fine but i want the Email Address text box to change to a red background color to show its an error and it doesnt want to do it:

document.getElementById("InputSource").style.backgroundcolor='red';


Im sure it must be something simple
Reply By: ssteward54 Reply Date: 7/28/2008 8:56:04 AM
Looks like backgroundColor should have the capital C in it.

Shawn Steward
Web Developer
www.shawnsteward.com

Go to topic 73006

Return to index page 1