Click here to Skip to main content
13,298,818 members (38,109 online)
Rate this:
Please Sign up or sign in to 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 28-May-12 15:18pm
SAKryukov 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?
ryanb31 29-May-12 9:57am
Need more details.
Prasad_Kulkarni 30-May-12 0:26am
Elaborate with some code..
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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 (?=.*[@#$%])

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171207.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100