Jump to content

Add a checkbox "Remember me"


Recommended Posts

Hi @deemuss,

Yes, it can be done with the jQuery code.  You should go to the editing Authentication screen, where there are two fields - Name and Password, for example. Add header and footer element and HTML block.

Put the following code to the header element for jQuery library: 

 

<script src="https://code.jquery.com/jquery-1.9.1.js"></script>

Put the following code into the HTML block for the "Remember me" checkbox:
 

<label class="checkbox">
    <input type="checkbox" value="remember-me" id="remember_me"> Remember me
</label>


Put the following code into the footer element for the jQuery code:
 

        <script>
            $(function() {
 
                if (localStorage.chkbx && localStorage.chkbx != '') {
                    $('#remember_me').attr('checked', 'checked');
                    $('#xip_Name').val(localStorage.usrname);
                    $('#xip_Password').val(localStorage.pass);
                } else {
                    $('#remember_me').removeAttr('checked');
                    $('#xip_Name').val('');
                    $('#xip_Password').val('');
                }
 
                $('#remember_me').click(function() {
 
                    if ($('#remember_me').is(':checked')) {
                        // save username and password
                        localStorage.usrname = $('#xip_Name').val();
                        localStorage.pass = $('#xip_Password').val();
                        localStorage.chkbx = $('#remember_me').val();
                    } else {
                        localStorage.usrname = '';
                        localStorage.pass = '';
                        localStorage.chkbx = '';
                    }
                });
            });
 
        </script>

where  #xip_Name is an ID for the Name field and #xip_Password is an ID for the Password field.

Please see this screenshot for better understanding:

image.thumb.png.e552a87634a42619029f044dfbfcbff5.png


 

Link to comment
Share on other sites

  • 2 years later...
  • 11 months later...

So, I've entered the coding that was provided in this forum into the authentication to add a "Remember Me" checkbox but it does not work. The datapage form works fine but a caspio rep said the checkbox needs to be done in my html coding. How do I connect the data page form and remember me checkbox on my web page so visitors do not have to fill out form everytime to go to next page on website? Not sure what to do or if anyone can help (if any of this makes sense)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...