How to restrict length of EditText control?
All,
How do I restrict the length of an EditText to accept ONLY 3 characters.
The editText.characters property sets a default size, but the user can still type more than 3 characters in the field.
All,
How do I restrict the length of an EditText to accept ONLY 3 characters.
The editText.characters property sets a default size, but the user can still type more than 3 characters in the field.
I got it!!!
var win = new Window("dialog", "Limit 3");
var txtLimit3 = win.add("edittext");
txtLimit3.characters = 5;
txtLimit3.onChanging = function (){
howmany = txtLimit3.text;
if (howmany.length > 3){
txtLimit3.text = "";
txtLimit3.textselection = howmany.slice(0,3)
}
}
txtLimit3.active = true;
win.show();
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.