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
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!