facebook

Make A password

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #337598 Reply

    mugmonj
    Member

    How do you put a password on a app? I already tried to use the Password field but i could not figure it out.

    #337608

    nvts
    Member

    You have to use JS code in your app_custon.js file.

    Create a password field, then a button, attach the JS code to that button.

    Here is sample code for hard coded password. I pull mine for a db for security reasons.

    function accesspass()
    {
    var StoredAccessPass=”1234″;
    var AccessPass=$(‘#m1-screen-passwordField1’).val();

    if (StoredAccessPass==AccessPass)
    {
    phoneui.gotoScreen(‘#m1-screen2’, phoneui.transitions.SlideLeft);
    }
    else
    {
    alert(‘Sorry, Wrong password’);
    }
    }

    Cheers…

    #337620

    mugmonj
    Member

    So this is the code that I linked to the button where do i input my password and the link to what I want to lock?
    Thanks J

    function accesspass()
    {
    var StoredAccessPass=”1234″;
    var AccessPass=$(‘#m1-screen-passwordField1’).val();

    if (StoredAccessPass==AccessPass)
    {
    phoneui.gotoScreen(‘#m1-screen2’, phoneui.transitions.SlideLeft);
    }
    else
    {
    alert(‘Sorry, Wrong password’);
    }
    }

    #337622

    nvts
    Member

    You need to create 2 screens. The first screen will have the password textarea and a button.

    Then that button will call the js script in you app_custom.js file with the accesspass(); in the run javascript

    If there in no fields created on the second screen you will need to add that screen to the additional project files under the first screen.

    The when you run the app you will enter the password and press the button and it correct it will go to the second screen and it it is wrong, it will show the alert message.

    Cheers…

    #337625

    mugmonj
    Member

    What do you have to change in the script for the button to make it work properly?
    Thank You J

    #337627

    nvts
    Member

    You have to go to the actions for the button and select run javascript and place the function call that was posted above to run when clicked.

    Cheers…

    Edited:

    I added a zip file that has a password & landing screen. Look at the button action on the password screen and look at the password_custom.js file for the accesspass() function.

    Attachments:
    You must be logged in to view attached files.
    #337629

    mugmonj
    Member

    this is what i’ve done view link and it still says error

    #337631

    nvts
    Member

    Yours has a lot of missing items. It was just my example you needed to change screen and screen2 to your .mobi name like login for screen.

    Did you download mine and try. It should run fine as i tested before zipping.

    Cheers…

    #337632

    mugmonj
    Member

    Thank You Works Great!!
    Thank You J

    #337633

    nvts
    Member

    Your welcome.

    I always put my javascript into the appname_custom.js file and then call it when needed as a function, like the button.

    Cheers…

    #337634

    mugmonj
    Member

    How do I change Password From 1234 to something else?

    #337635

    nvts
    Member

    It is hard coded in the password_custom.js file in the folder password-www. I edit with a editor. You can edit it through Mobione Test Center while running the app under tools/view source then select the password_custom.js file.

    Change var StoredAccessPass=”1234″;

    Save and reload.

    This is not very secure way of having a password. That is why I use a db to store my passwords as other data needed for my apps.

    Cheers…

Viewing 12 posts - 1 through 12 (of 12 total)
Reply To: Make A password

You must be logged in to post in the forum log in