Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET

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 14:18pm
imaile301
Comments
SAKryukov at 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
ryanb31 at 29-May-12 9:57am
   
Need more details.
Prasad_Kulkarni at 30-May-12 0:26am
   
Elaborate with some code..
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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

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



Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2014
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