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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.