Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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:

C#
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,}))$/;
    return re.test(email);
}
 
Share this answer
 
v2
Comments
venuchary 29-Sep-11 2:14am    
THANKS FOR YOUR RESPONSE ,
it is okay for windows application and asp.net application
this much of flexibility not available in windows mobile application

what ever u have given suggestion mobile application does not support.
any other alternative way
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
 
Share this answer
 
Comments
venuchary 29-Sep-11 2:14am    
THANKS FOR YOUR RESPONSE ,
it is okay for windows application and asp.net application
this much of flexibility not available in windows mobile application

what ever u have given suggestion mobile application does not support.
any other alternative way
If you are working on Windows Phone 7 Development, then have a look at below link.
Validating input forms in Windows Phone 7


In-case if you are working on earlier versions of Windows Mobile Development, then have a look at below link.(It does not contains exact code of your requirement, but hopefully it will provide you an idea around the topic.)
For Windows Mobile 6
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900