I'm been trying on getting the xmlhttp.responseText after calling out the function as i wish to do some show and hide objects. But it seems that I cant match the innerhtml and show the object like button.
Updated Javascript function:
function ShowHideDisplay(str)
{
xmlhttp = new XMLHttpRequest();
//It will echo whatever message into this response.text.
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("validate").innerHTML = xmlhttp.responseText;
}
//Using test
var successText = "<img src=\"./images/success.gif\" alt=\"Correct!\">Can be used";
document.getElementById("validate").innerHTML = responseText;
if(document.getElementById("validate").innerHTML.test(/success/gmi))
{
document.getElementById("submit").style.visibility = 'visible';
}
else
{
document.getElementById("submit").style.visibility = 'hidden';
}
}
HTML Form:
<input name="Numbers" type="text" id="Numbers" onkeyup="ShowHideDisplay(this);" value=""/>
<span id="validate"></span>
//wants to hide and show upon onkeyup and getting the span id of validate.innerhtml success message
<input name="submit" id="submit" type="submit">
I just need to get the span id of the validate value or innerhtml text to show and hide the button. But i try different ways yet it cant match the innerhtml text. Kindly advise.