I want to check the 10 digit phone number whether all 10 digits are same or different. If same means Invalid mobile number alert will be displayed. I want a code in LWUIT.
Asked
Active
Viewed 839 times
1 Answers
5
set the TextField
max size to 10. It allows only 10 digits. Also set the numeric constraint to that TextField
. It allows only numeric value. See the sample code,
TextField txtf = new TextField();
txtf.setConstraint(TextField.NUMERIC);
txtf.setInputModeOrder(new String[] {"123"});
txtf.setMaxSize(10);
form.addComponent(txtf);
Also check the length of the text in TextField
. If length isn't 10 digit, you can showing the alert.
For checking repeated numbers, Use addDataChangeListener
. You can handle the validation inside of this listener.

bharath
- 14,283
- 16
- 57
- 95
-
2good answer but you should not help question like "i want code" – frayab Feb 06 '12 at 08:35
-
@ frayab, He wants to write an own logic on `addDataChangeListener`. Then only he knows about how to write and how to handle the code. right? – bharath Feb 06 '12 at 09:40
-
I'll add that there is also a phone number constraint that should work for native editing. This is very valuable in Codename One where the iOS/Android ports actually provide a different keyboard for phone number input. – Shai Almog Feb 10 '12 at 05:33