Hi all. I am trying to workout how to show the default value of a text box when you click off it. I have already got the code for the onclick but I would appreciate some help with the offclick.
Thanks in advance.
Cameron
Hi all. I am trying to workout how to show the default value of a text box when you click off it. I have already got the code for the onclick but I would appreciate some help with the offclick.
Thanks in advance.
Cameron
What is offclick??? Do you mean if the text box was focused but a user does not fill value in it, a default value will be display when the user moves the focus to another element? Is it something like the sample code below?
<html>
<head>
function displayDefaultValue(inputElement) {
if (inputElement && inputElement.value.replace(/\s+/g,"")=="") {
inputElement.value = "My Default Value"
}
}
</head>
<body>
<input type="text" onchange="displayDefaultValue(this)">
</body>
</html>
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.