I created a FiddleFiddle that probably does what you want.
The HTML
<input id="submit" type="submit" /> <span id="validate"></span> The JavaScript
/* Success */ var responseText = "<img src=\"./images/success.gif\" alt=\"Correct!\">Can be used"; /* Failure */ //var responseText = "<img src=\"./images/Failed.gif\" alt=\"Incorrect!\">Can not be used"; /* Assign content */ document.getElementById("validate").innerHTML = responseText;responseText || ""; /* Change visibility based on outcome (success or not) */ if(document.getElementById("validate").innerHTML.test(/success/gmi)) { document.getElementById("submit").style.visibility = 'visible'; } else { document.getElementById("submit").style.visibility = 'hidden'; } Test with a regular expression if the word 'success' was in the result or not. This way it doesn't really matter what the HTML in the response is.
Note There is no <success> element in HTML, use a span or div with class success.
PS. If you can you should only return the word true or false or success or failure instead of HTML and render the text plus image on the client.