LWUIT中的手机号码验证 [英] Mobile Number Validation In LWUIT

查看:97
本文介绍了LWUIT中的手机号码验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查10位电话号码是否全部10位相同或不同.如果相同,则将显示无效的手机号码警报.我想要LWUIT中的代码.

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.

推荐答案

TextField的最大大小设置为10.它仅允许10位数字.还要将数字约束设置为该TextField.它仅允许数字值.查看示例代码,

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);

还要检查TextField中文本的长度.如果长度不是10位数,则可以显示警报.

Also check the length of the text in TextField. If length isn't 10 digit, you can showing the alert.

要检查重复的数字,请使用 addDataChangeListener .您可以在此侦听器内部处理验证.

For checking repeated numbers, Use addDataChangeListener. You can handle the validation inside of this listener.

这篇关于LWUIT中的手机号码验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆