Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

Show Password checkbox

I could not find any answer to "How do I create a 'Show Password' checkbox" in this forum. Here is my solution. This assumes the following:
A. It is on the page named startScreen.
B. The input component for your password is named password.

  1. Create the checkbox labeled "Show Password"

  2. Add Event to the checkbox: Event is Click, Action is Run Javascript

  3. Put in the following Javascript:
    codeif ($('#startScreen_show_password').attr('checked')) {
    $('#startScreen_password')[0].setAttribute('type','password');
    } else {
    $('#startScreen_password')[0].setAttribute('type','text');
    }
    return true;
    /code

    Interestingly, in a normal web page, if the checkbox is checked when you click it, by the time the function is run it is not checked (assuming you get there by having "onclick" in the checkbox). However, here it is still checked when the function is run.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Show Password checkbox

Thanks for sharing. I'll add a link to our documentation.

Fred McIntyre
Posts: 0
Joined: Sun Jan 12, 2014 5:04 pm

Show Password checkbox

I have found that the above solution does not work very consistently. Here is what I am now actually using, which has been tested on an Android phone (the above was not tested on a phone).

This assumes the input component for your password is named "password" and is a password type.

  1. Add a Checkbox group with one item.

  2. The name of the one check box item should be "show_password" (or change the Javascript below to use whatever name you put in).

  3. Put whatever text you like on the check box item, like "Show Password"

  4. Add an input component, type text. Uncheck Visible so it is hidden. Name it "plainpassword"

  5. Add Event to the Checkbox group, not the item. Event is Value change, Action is Run Javascript.

  6. Put in the following Javascript:
    preif ($('input', Appery("show_password")).prop("checked")) {
    Appery('password').val(Appery('plainpassword').val());
    Appery('plainpassword').val('');
    Appery('password').show();
    Appery('plainpassword').hide();
    } else {
    Appery('plainpassword').val(Appery('password').val());
    Appery('password').val('');
    Appery('plainpassword').show();
    Appery('password').hide();
    }/pre

    This will hide the password input and show the plaintext input when the check box is checked. (The logic in the "if" above seems backwards, but this is how it works.) It will copy the value of the password input to plainpassword, and make password blank. When it is not checked it does the opposite.

    Add this Javascript to the Click event of your Login button (or whatever it is that causes the page to be sent to the Service). Make sure it comes before Invoke service:
    preif (Appery('password').val() === '') {
    Appery('password').val(Appery('plainpassword').val());
    }/pre

    This checks to see if the password field has a value. If it does not, then it must be that the plainpassword is showing, and it copies that value to the password field.

    Instead of adding that action to the Click event of the login button, I have modified my REST service to look for the parameter plainpassword if the password parameter is blank. And in my validation on my log in page I use this:
    prevar error = '';
    if ($.trim(Appery('username').val()) === '') {
    error = 'Please enter your user name.
    ';
    }
    if ($.trim(Appery('password').val()) === '' && $.trim(Appery('plainpassword').val()) === '') {
    error = error + 'Please enter your password.
    ';
    }
    if (error === '') {
    loginService.execute({});
    return true;
    } else {
    localStorage.setItem('error',error);
    Appery.navigateTo('error_popup', {
    transition: 'pop'
    });
    return false;
    }/pre

    The popup named error_popup, on Page Show, gets the value of the localStorage error, and puts it into a label on the popup.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Show Password checkbox

Thank you for sharing!

Aisha Aslam
Posts: 0
Joined: Wed Aug 27, 2014 4:47 am

Show Password checkbox

sir
i have to build an android app for my project, as i am new with android programming that's why i need your help in this. sir i have tried to build an app from your website but i need more help from you people so i should be able to complete my project ..i need to build an android app which contain 8 or 9 buttons and functionality of the button should be such that when i press a button(for car start) it should open the new window which further contain two buttons 1-start with blue tooth 2- start with GSM (i-e through text message) and when i press the 1st button it should automatically open the blue tooth app installed on my cell phone and like wise when i press the 2nd button it should automatically open the create message icon of my cell phone ..please help me out in this

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Show Password checkbox

Aisha,

Please, find our reply here: https://getsatisfaction.com/apperyio/...

Return to “Issues”