Ajax change textbox bgcolor after Criteria met
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.backg roundcolor='red';
VarResult = xmlHttp.responseText;
document.getElementById("txtHint").innerHTML=VarRe sult;
}
}
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.backg roundcolor='red';
Im sure it must be something simple
|