JavaScript that changes Text box to blank when clicked

Here is a quick example. http://jsfiddle.net/9NTbX/

<html>
<input type=”text” id=”UserName” name=”UserName” value=”UserName” onclick=”usernametoblank_clickHandler();”>
</html>

<script>
function usernametoblank_clickHandler() {

var val = document.getElementById(“UserName”).value;

if (val ==  “UserName”) {
document.getElementById(“UserName”).value = “”;
}
}
</script>

Please follow and like us: