I am attempting to compare the input text to an xml tag for validation purposes and Im having some trouble. My error is with the conditional in the calling() function (i think):
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}
else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","userPass.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
function calling(){
if(document.getElementById("userName").innerHTML==
(xmlDoc.getElementsByTagName("user")[0].childNodes[0].nodeValue){
alert("this is valid");
}
}
<form name="input" action="userPass.xml" method="post">
username <input type="text" id="userName" onchange="calling()" /><br/><br/>
password <input type="password" id="password"/><br/><br/>
<input type="submit" value="Submit" />
</form>
Thanks for taking the time to help-
I think you are missing a closing parenthesis in the condition for the if statement. Also, you may want to test the value property of the input instead of innerHTML. Your function should look like this:
This is my guess. I can’t help you any further without knowing what kind of problems you are running into or what the response from the server looks like.