Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Password and TextBox Value.

Hi,

My question is how to create a password field in the Titanium.For an example to create a text field we have var textfield = Titanium.UI.createTextField.

In a new window I have added a label,textbox and a button.When I have clicked that button how to get a textbox value.

Please provide me a solution to solve the problem.

Thanks and Regards,
Venkatesan.R

— asked December 1st 2010 by venkatesan ramdoss
  • textb
0 Comments

1 Answer

  • Hi venkatesan

    I hope this gets you started:

    var win1 = Ti.UI.createWindow({  
        backgroundColor:'white',
        navBarHidden:false,
        title:'Login window 1'
    });
    
    var view1 = Ti.UI.createView({
        backgroundColor:'blue',
        borderRadius:5,
        layout:'vertical',
        top:20,
        height:155,
        width:300
    });
    win1.add(view1);
    
    var username = Ti.UI.createTextField({
        hintText:'Enter your username',
        top:10,
        left:10,
        right:10
    });
    view1.add(username);
    
    var password = Ti.UI.createTextField({
        hintText:'Enter your password',
        passwordMask:true,
        top:5,
        height: 45,
        left:10,
        right:10
    });
    view1.add(password);
    
    var button = Ti.UI.createButton({
        title:'Login',
        left:50,
        right:50,
        top:8,
        height: 35
    });
    view1.add(button);
    
    button.addEventListener('click', function(){
        username.blur();
        password.blur();
        // do something sensible
        var alertDialog = Ti.UI.createAlertDialog({
            title: 'Login Successful',
            message: 'You have logged in with a username of "'+username.value+'"',
            buttonNames: ['OK']
        });
        alertDialog.show();
    });
    
    win1.open();
    

    It should run without issue if you paste it into your app.js file.

    Good luck!

    — answered December 1st 2010 by Paul Dowsett
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.