Load a modal after 5 mins inactive in the browser

Load a modal after 5 mins inactive in the browser
<script type="text/javascript">

function idleTimer() {
    var t;

    window.onload  = resetTimer; # catches windows reload

    window.onmousemove  = resetTimer; # catches mouse movements

    window.onmousedown  = resetTimer; # catches mouse movements

    window.onclick  = resetTimer; # catches mouse clicks

    window.onscroll  = resetTimer; # catches scrolling

    window.onkeypress  = resetTimer; #catches keyboard actions


    function showModal() {

        #"Your idle time is 20 minutes over")

        #show modal now

    }


   function resetTimer() {

        clearTimeout(t);

        t = setTimeout(showModal, 1200000);  # [time is in milliseconds (1000 is 1 second)]

    }

}


# Execute the IdelTimer()
# idleTimer();

</script>
Please follow and like us:
0

Jquery validation min and max length

Min length method:

Description: Makes the element require a given minimum length.

Return false if the element is

  • some kind of text input and its value is too short
  • a set of checkboxes that doesn’t have enough boxes checked
  • a select and doesn’t have enough options selected

Works with text inputs, selects and checkboxes.

Makes “field” required having at least 3 characters.

<!doctype html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Makes "field" required having at least 3 characters.</title> 

<link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css"> 
</head> 
<body> 
<form id="myform">
    <label for="field">Required, minimum length 3: </label> 
    <input type="text" class="left" id="field" name="field"> 
    <br/> 
    <input type="submit" value="Validate!"> 
</form> 
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script> 
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
 
<script> 
// just for the demos, avoids form submit 

jQuery.validator.setDefaults({ 
    debug: true, 
    success: "valid" 
}); 

$( "#myform" ).validate({ 
    rules: { 
       field: { 
          required: true, 
          minlength: 3 
       } 
    } 
}); 
</script> 
</body>
</html>
Please follow and like us:
0