Thursday, April 21, 2011

VB(Regex of dont allow special characters)

Dim objReg = New Regex("\s*[.-]*[^\W_]")

'This will allow only "<Spaces>,-,."
TryIf Not objReg.IsMatch(textboxname.Text) Then
objReg = NothingThrow New Exception("Special Characters Are Not Allowed In Suburb")
End If
Catch ex As Exception
lblError.Text = ex.Message
End Try




NOTE:
To Change It in C# Use The VB to C# Converter Which are easily available on the Internet.



           


No comments:

Post a Comment