exact time upon button click - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Button


exact time upon button click

Demo Code

ResultView the demo in separate window

      <title>Button Click</title> 
      <script type="text/javascript">
      function filter_seconds(date){
          return date.replace(/(\d{1,2}\:\d{1,2})\:\d{2}/, '$1')
      }//ww  w .  ja  v  a2 s.c om
      <input type="text" id="date" value=""> 
      <input id="button" 
             value="Get the Date!" 
             onclick="document.getElementById('date').value = filter_seconds(new Date().toLocaleTimeString(navigator.language))">  

Related Tutorials