Member Avatar for doctorphp

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>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.