Check if a textbox contains characters or a string
Sunday 20 April 2008
If you want to check a textbox to see if it contains a character or a certain string, follow the below format.:
- If Textbox1.Text.Contains("http://") Then
- Response.Write("Success")
- End If
You could place whatever code you want in place of Response.Write, to do what ever you want. A variation of the above could be handy as a basic anti-spam post filter. Something like below:
- If Textbox1.Text.Contains("http://") OR Textbox1.Text.Contains("www.") Then
- Response.Write("Success")
- End If
If you wanted to check a string for a character or a string, do the below:
- Dim str As String = Textbox1.Text
- If str.Contains("http://") Then
- Response.Write("Success")
- End If
|
(0)
|
|
|