Mobile Number Validation In LWUIT [closed]

↘锁芯ラ 提交于 2019-12-14 03:35:56

问题


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.



来源:https://stackoverflow.com/questions/9156737/mobile-number-validation-in-lwuit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!