dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: How to Reset Form when User Inactive?

  1. #1
    Join Date
    Aug 2014
    Posts
    1

    How to Reset Form when User Inactive?

    Dear Sirs!
    I cannot find answer on that simple question for hours...

    I find a lot advices with Button (Reset value) but I cannot press it by timer inactivity.

    When I tried {window.location=default} then it clear all my styles formats too so I need in "press Reset button by timer inactivity of keypress"

    I use JavaScript, PHP (webserver and client use the same machine) and virtual keyboard (not mouse!) on sensor kiosk.

    Please answer me in JavaScript or PHP.

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,587
    You need a function that resets a timer each time a key is pressed or a mouse click happens or mouse is moved.

    Your timer reset would be bound to all those events and when the time has lapsed your script would need to redirect to a page that is informing the user that they have timed out or you have JavaScript replace the page with a notice.

    Either way, your script will rely upon a number of factors, the user having JavaScript and browser(s) that supports the event listeners for your timeout script to work.
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Jun 2004
    Location
    Portsmouth UK
    Posts
    2,693
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
    <form name="myform" >
     <input name="" />
    
    </form>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    function zxcResetTimer(o){
     var frm=document.forms[o.FormName],s=o.Delay;
     if (frm){
      o.frm=frm;
      o.s=(typeof(s)=='number'&&s>0?s:60)*1000
      this.addevt(document,'click','Reset',o);
      this.addevt(document,'mousemove','Reset',o);
     }
    }
    
    zxcResetTimer.prototype={
    
     Reset:function(o){
      clearTimeout(o.to);
      o.to=setTimeout(function(){ o.frm.reset(); },o.s);
     },
    
     addevt:function(o,t,f,p,p1){
      var oop=this;
      o.addEventListener?o.addEventListener(t,function(e){ return oop[f](p,p1);},false):o.attachEvent?o.attachEvent('on'+t,function(e){ return oop[f](p,p1); }):null;
     }
    
    
    
    }
    
    new zxcResetTimer({
     FormName:'myform',
     Delay:3             // seconds
    });
    /*]]>*/
    </script></body>
    
    </html>
    Vic

    God loves you and will never love you less.

    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles