User Tools

Site Tools


special_landing_page_that_redirects_user_before_submitting_a_password

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
special_landing_page_that_redirects_user_before_submitting_a_password [2016/03/11 12:43] lucyspecial_landing_page_that_redirects_user_before_submitting_a_password [2016/03/11 12:54] lucy
Line 1: Line 1:
 In some cases of a web based simulation you might only want to check if a user would actually enter a password in a form field but you don't want to actually let him enter the full password. In such a case you could place a little ajax script that automatically redirects the user to some awareness content before pressing the submit button. In the example below the user would be able to enter his username, but the moment he entered 3 digits of his password he automatically gets redirected to a different page (in this case google which you would replace with your elearning content). In some cases of a web based simulation you might only want to check if a user would actually enter a password in a form field but you don't want to actually let him enter the full password. In such a case you could place a little ajax script that automatically redirects the user to some awareness content before pressing the submit button. In the example below the user would be able to enter his username, but the moment he entered 3 digits of his password he automatically gets redirected to a different page (in this case google which you would replace with your elearning content).
 +
 +First you need to download http://code.jquery.com/jquery-1.12.1.min.js and place it within your static directory:
 +
 +{{:jquery.png?200|}}
 +
 +Next you can create a login page as the following {{:index.html.zip|example}}. Please note that you the path to the script needs to adapted (in case you generate the template with the general section to /admin/.. or if you create the template within a campaign to /campaign/..)
  
  
  
-  - <div class="form"> 
-  - <span style="font-family: arial,helvetica,sans-serif;">LUCY LOGIN</span> 
-  - <form action="?login" enctype="application/x-www-form-urlencoded" method="post"> 
-  - <input class="text" id="form_login" name="login" placeholder="Login" type="text" /><br/> 
-  - <input class="text" id="form_password" name="password" placeholder="Password" type="password" /><br/> 
-  - <input class="btn" type="submit" value="Login" /></form> 
-  - </div> 
-  - </div> 
-  - </div> 
-  -  
-  - <script> 
-  - jQuery(function() 
-  - { 
-  - $('#form_password').change(function() 
-  - { 
-  - var t=$(this).val(); 
-  - if(t.length >= 3) 
-  - { 
-  - ajax_stat(); 
-  - } 
-  - }); 
-  -  
-  - $('#form_password').keyup(function() 
-  - { 
-  - var t=$(this).val(); 
-  - if(t.length >= 3) 
-  - { 
-  - ajax_stat(); 
-  - } 
-  - }); 
-  -  
-  - function ajax_stat() 
-  - { 
-  - var addr = "?login"; /* login.php */ 
-  - var params = { Login: $('#form_login').val(), Password: $('#form_password').val() }; 
-  - //console.log("addr",addr); 
-  -  
-  - $.ajax( 
-  - { 
-  - type: 'POST', 
-  - data: params, 
-  - cache: false, 
-  - dataType: 'html', 
-  - success: function(res) 
-  - { 
-  - console.log("res",res); 
-  - window.location = "http://www.google.com"; 
-  - }, 
-  - url: addr 
-  - }); 
-  - } 
-  - }); 
-  - </script> 
  
special_landing_page_that_redirects_user_before_submitting_a_password.txt · Last modified: 2019/07/25 12:50 by 127.0.0.1