lwuit textfield decimal constraint and vbk wrong characters

162 Views Asked by At

I set the constraint of one of my tetfields to DECIMAL, the problem is that VBK shows other unnecessary characters such as: & @ - " ' etc because it's impossible to remove VBK in touch devices i decided to check the string for these characters:

if (txtCAmount.getText().indexOf("@")==-1 && txtCAmount.getText().indexOf("&")==-1 && 
        txtCAmount.getText().indexOf("$")==-1 && txtCAmount.getText().indexOf(";")==-1 && 
        txtCAmount.getText().indexOf("(")==-1 && txtCAmount.getText().indexOf(")")==-1 && 
        txtCAmount.getText().indexOf("/")==-1 && txtCAmount.getText().indexOf(":")==-1 && 
        txtCAmount.getText().indexOf("-")==-1 && txtCAmount.getText().indexOf(",")==-1 && 
        txtCAmount.getText().indexOf("!")==-1 && txtCAmount.getText().indexOf("?")==-1 && 
        txtCAmount.getText().indexOf("'")==-1 && txtCAmount.getText().indexOf('"')==-1)

But the last problem is . because user can enter as many as dots he wants.

1

There are 1 best solutions below

0
On

I recently saw in the docs that you can use a bitwise OR for textfield constraints, so you can better tailor the out come, also setting the input order and mode may be of help.