Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:

Let say , if my input is grouped into 4 types and there should be a button to check the valid of each input.

How am i goin to code the button to check for the valid of my input?
Posted
Comments
Sergey Alexandrovich Kryukov 28-May-12 20:30pm    
You don't have to "code the button"; the button is already "coded". :-)
What did you try? What's the problem? Important: tag your application type or UI you want to use: WPF? Forms? Silverlight? ASP.NET? What?
--SA
ZurdoDev 29-May-12 9:57am    
Need more details.
Prasad_Kulkarni 30-May-12 0:26am    
Elaborate with some code..

If you are using ASP.NET you could use the validation controls available to check if each field is required (RequiredFieldValidator), meets a specific expression (RegularExpressionValidator), is in a specific range (RangeValidator) or not or you can compare fields (CompareValidator) or even write your own validator (CustomValidator) in client or server side.

Your button is by default CausesValidation="true" and you can set a ValidationGroup if need be. Each field in the same ValidationGroup as your button will be validated accordingly.
 
Share this answer
 
Hi,
The easiest way is to use a regular expression to check if the entered string is valid. The expression ((?=.*\\d)(?=.*[A-Za-z])(?=.*[@#$%])) will check if the entered string contains at least 1 number(?=.*\\d), 1 letter(either upper or lower case(?=.*[A-Za-z]) and 1 character in the list (?=.*[@#$%])
 
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