I guess the title say it all:
Search term to find function to clear textbox unless exits with blank value?
I’m trying to find a function that clears a textbox of the default entry
and allows user to put in information. Would keep textbox value
unless exits with a blank value, in which case the default prompt is
replaced into the textbox.
I’ve tried searching with:
‘erase text on entry’
‘blank prompt textbox’
and several other combinations. 😮
I’ve tried the following, but it’s not working and I’m not getting any errors in FF? ?
[code]
<html>
<head>
<title>Clear Textbox Prompt</title>
<script type=”text/javascript”>
// From: http://www.webdeveloper.com/forum/showthread.php?p=1044548#post1044548
function clsIn(info,Msg) {
promptMsg = Msg;
if (info.name.value == Msg) { info.name.value = “”; }
}
var promptMsg = ”;
function clsOut(info) {
if (info.name.value == ”) { info.name.value = promptMsg; }
}
</script>
</head>
<body>
<form name=’myForm’ onsubmit=”return false”>
<input type=”text” value=”Last name” onfocus=”clsIn(this,’Last name’)” onblur=”clsOut(this)” name=’lname’ />
<input type=”text” value=”First name” onfocus=”clsIn(this,’First name’)” onblur=”clsOut(this)” name=’fname’ /><br>
<input type=”text” value=”Address” onfocus=”clsIn(this,’Address’);” onblur=”clsOut(this)” name=’addr’ /><br>
<input type=”text” value=”City” onfocus=”clsIn(this,’City’);” onblur=”clsOut(this)” name=’city’ />
<input type=”text” value=”State” onfocus=”clsIn(this,’State’);” onblur=”clsOut(this)” name=’state’ /><br>
<input type=”text” value=”Zip” onfocus=”clsIn(thisIn,’Zip’);” onblur=”clsOut(this)” name=’zipcode’ />
</form>
</body>
</html>