Validate and set input field value when losing focus - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Date

Description

Validate and set input field value when losing focus

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*from   w  w w  . jav a  2s  .c o m*/
document.getElementById("searchtextbox").onblur = function() {
    if (this.value == "") {
        this.value="Search...";
    }
}
    });

      </script> 
   </head> 
   <body> 
      <input type="text" id="searchtextbox" value="">  
   </body>
</html>

Related Tutorials