Skip to main content

Alphanumeric input mode for textfield

10 replies [Last post]
lina_gsp
Offline
Joined: 2010-03-27
Points: 0

Hi guys ;-)
I'm developing a login panel using LWUIT and I need to have the password field as an alphanumeric input field.I've set setConstraint(TextArea.PASSWORD) but I don't konw how I can use setInputMode() function to accept only alphanumeric inputs.
Can anyone here help me on this problem????
Thanks ;)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lina_gsp
Offline
Joined: 2010-03-27
Points: 0

Oops sorry I just saw your edited message.... well it didn't work.... I guess I should implement the filtering function yup?

bhakki
Offline
Joined: 2009-09-09
Points: 0

I used like this.
It vl be working for me.
What u passed in the setSymbolTable(...) method?

Bharath...

lina_gsp
Offline
Joined: 2010-03-27
Points: 0

private char[] table = {'a','b','c'};

newTF = new ArmTextField();
newTF.setSingleLineTextArea(true);
newTF.setConstraint(TextArea.PASSWORD);
newTF.setInputModeOrder(new String[]{"Abc","123"});
newTF.setSymbolTable(table);

ArmTextField is a container class that has a textfield object in it. and this is the code in ArmTextField:

public void setSymbolTable(char[] table){
textField.setSymbolTable(table);
}

bhakki
Offline
Joined: 2009-09-09
Points: 0

why u r passing a,b,c to symbol table?
Just u passing the special symbols what u need...

lina_gsp
Offline
Joined: 2010-03-27
Points: 0

I just want to have a,b,c for my password.(for example..)

lina_gsp
Offline
Joined: 2010-03-27
Points: 0

Well thanks guys ;-) I solved it but just a line of code ....
for having an alphanumeric textfield I just check the Ascii code of letters... here is the sample code :

int code = (int) newPassword.charAt(i);
if (!((code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122)))

System.out.println("Wrong Char.....")

;-)

bhakki
Offline
Joined: 2009-09-09
Points: 0

Hi,
try like this,

TextField textField = new TextField();
textField.setInputModeOrder(new String[]{"Abc","123"});

And you need to pass new symbol table to this method
textField.setSymbolTable(char[] symbolTable);

Here u can mention what are all the symbols you need...

Bharath...

lina_gsp
Offline
Joined: 2010-03-27
Points: 0

thanks for your quick reply ;-)
here is the code:
newTF.setConstraint(TextArea.PASSWORD);
newTF.setInputModeOrder(new String[]{"Abc","123"});

one more question,is there any function by which special character inputs can be avoided or I should implement it by myself? I don't want to have %$& .....

bhakki
Offline
Joined: 2009-09-09
Points: 0

U can use ur own symbol table with what are all the symbols u need.
And u need to pass the that symbol table into setSymbolTable(....) method.

Bharath....

lina_gsp
Offline
Joined: 2010-03-27
Points: 0

it's exactly what I'm doing... here is the code:

private char[] table = {'a','b','c'};

newTF = new ArmTextField();
newTF.setSingleLineTextArea(true);
newTF.setConstraint(TextArea.PASSWORD);
newTF.setInputModeOrder(new String[]{"Abc","123"});
newTF.setSymbolTable(table);

ArmTextField is a container class that has a textfield object in it. and this is the code in ArmTextField:

public void setSymbolTable(char[] table){
textField.setSymbolTable(table);
}