Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I want know how to do following validations in VB.Net on Textbox for eg i have form like this :

Name : textbox(i want only Alpha Validation Here

Address : Textbox (i want Alpha Numeric Validation Here

Number : Textbox (i want Only Numeric validation here

Monthly Fees : i want Amount validation here like 10,000 like commas , Decimal Points

Kinly Please Help Me
Posted
Comments
[no name] 21-Aug-14 1:38am    
It's a web or windows application..??
Member 11014751 21-Aug-14 1:54am    
Tell Me for both if possible ,
Now i want for Windows

First off, validating names to alpha only is a poor idea - you can't guarantee that names will only contain A-Z, a-z
Non-Western names, idiot parents, legal change-of-names can all add characters outside that range

Address: same problem.

But numbers are easy: integer.TryParse or double.TryParse will check and convert strings to numbers allowing for local number format settings: remember that 1,000.345 is not the only format: 1.234,567 is legal in many places.
 
Share this answer
 
Comments
Member 11014751 21-Aug-14 2:51am    
Thanks but in names and address fields i dont want anyone to write special characters . In name only A-Z-a-z allowed . i want email validation also
OriginalGriff 21-Aug-14 4:12am    
And what have you done so far?
add your own function to check whatever you want.


Private Function isvalidnumeric(ByVal pobject As Object) As Boolean
Dim linti As Integer
Dim lstrnumeric As String = "0123456789.,"

For i = 1 To Len(pobject)
If InStr(lstrnumeric, Mid(pobject, i, 1)) = 0 Then
isvalidnumeric = False
Exit Function
End If
Next

isvalidnumeric = True
End Function
 
Share this answer
 
v3
Comments
Member 11014751 21-Aug-14 3:31am    
Thanks Numeric is Done , How to do for Alpha, AplhaNumeric & Amount
Member 11014751 21-Aug-14 7:10am    
Please Give me for Alpha, AplhaNumeric & Amount
kgmmurugesh 21-Aug-14 7:19am    
only change the lstrnumeric string to "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" for alpha, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789" for alpha numerice, "1234567890.,$" for amount.
Member 11014751 21-Aug-14 7:38am    
This Code Not Working
kgmmurugesh 21-Aug-14 10:18am    
give me your code

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