为移动应用程序中的文本框提供验证 [英] providing the validation for textbox in mobile application

查看:84
本文介绍了为移动应用程序中的文本框提供验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想为移动应用程序
中的文本框提供验证
1)Textbox1仅允许数字
2)Textbox2仅允许使用字符
3)Textbox3仅允许使用电子邮件.

以上所有文本框必填字段.

可以给我关于这个的任何建议吗

Hi every body,

i want to provide the validation for the text boxes in mobile application

1) Textbox1 allow only numbers
2) Textbox2 allow only characters
3) Textbox3 allow only email.

all above text boxes mandatory fields.

could please give to me any suggestion on this one

推荐答案

您可以使用javascript函数

请参阅此链接以获取数字和字母
http://answers.oreilly.com/topic/134-how-to-allow-only-numbers-or-letters-in-a-text-box-with-javascript/ [
You can use javascript functions

Refer this link for numbers and letters
http://answers.oreilly.com/topic/134-how-to-allow-only-numbers-or-letters-in-a-text-box-with-javascript/[^]

For Email:

function validateEmail(email) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\
".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA
-Z\-0-9]+\.)+[a-zA-Z]{2,}))


/; 返回re.test(email); }
/; return re.test(email); }


您可以使用自定义验证程序来实现.我建议使用CustomValisator而不是RegularExpressionValidator,因为您还需要根据需要输入字段.使用CustomValidator控件可以轻松实现这一目标.

要了解Custom Validator控件,请参阅
1.
ASP.NET中的自定义验证摘要 [ http://asp.net-tutorials.com/validation/custom-validator/ [ ^ ]

使用CustomValidatorControl后,可以将正则表达式放在javascript代码中以验证文本框中的数据
1.仅用于数字的正则表达式:[0-9]*
2.仅用于字符的正则表达式:[A-Za-z]*
3.电子邮件的正则表达式:\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

希望这会有所帮助.
一切顺利
You can use the custom validator to achieve this. I recommend CustomValisator over RegularExpressionValidator for the reason that you also need the fields as required. This thing can be easily achieved using CustomValidator control

To get stared with Custom Validator control refer
1. Custom Validation Summary in ASP.NET[^]
2. http://asp.net-tutorials.com/validation/custom-validator/[^]

Once you use the CustomValidatorControl, you can put the regular expression in the javascript code to validate the data in the textbox
1. Regular Expression for Number only : [0-9]*
2. Regular Expression for Characters only : [A-Za-z]*
3. Regular Expression for Email : \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b

Hope this helps.
All the best


这篇关于为移动应用程序中的文本框提供验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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