Thursday, June 14, 2007

Check Time with a Regular Expression in javascript

copy following code to save a html file, and run it.
  <script type="text/javascript">
  function check_time()
    var elem = document.getElementById('timeStr');
    var orig_str = elem.value;
    //24 hour
    var _reg = new RegExp(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
  <input type="text" id="timeStr">
  <input type="button" value="test" onclick="check_time()" />
Blogger Template Layout Design by [ METAMUSE ] : Code Name Gadget 1.1 Power By & Programming Blogs - BlogCatalog Blog Directory