473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Validation Controls

Hi

I am looking for validation controls for email, URL etc. similar to those
provided by ASP.NET 2005

Thank you,
Samuel
Dec 17 '06 #1
4 1127

Samuel Shulman wrote:
Hi

I am looking for validation controls for email, URL etc. similar to those
provided by ASP.NET 2005

Thank you,
Samuel
You can use reg expressions to see if the contents of the control is a
valid emai, url, etc.

dag regurlar expressions vb.net

Dec 19 '06 #2
Thanks,

All I found is the MaskedTextBox control and the Mask property which doesn't
have a mask for email or URL address

Cheers,
Samuel

<fa***********@gmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
>
Samuel Shulman wrote:
>Hi

I am looking for validation controls for email, URL etc. similar to those
provided by ASP.NET 2005

Thank you,
Samuel

You can use reg expressions to see if the contents of the control is a
valid emai, url, etc.

dag regurlar expressions vb.net

Dec 19 '06 #3

Samuel Shulman wrote:
Thanks,

All I found is the MaskedTextBox control and the Mask property which doesn't
have a mask for email or URL address

Cheers,
Samuel
You can write a class that inherits the MaskedTextbox and uses regular
expressions for validation. It's pretty easy.

Here's an old piece of code I found for doing that:
(It could probably use a bit of work though - I have a newer version,
but not on this computer)
''' <summary>
''' This class is a text box that will make sure that its input only
contains text matching its
''' regular expression.
''' </summary>
''' <remarks>If the user attempts to enter a character that causes the
text to not match the
''' regular expression, then the text will be reverted to what it was
before the user's action.</remarks>
Public Class regexpTextBox
Inherits System.Windows.Forms.TextBox

Protected myRegex As New System.Text.RegularExpressions.Regex(".*",
System.Text.RegularExpressions.RegexOptions.Compil ed)

Protected myRegexStr As String
Protected myStr As String = ""

''' <summary>
''' Gets or sets the string representation of this regexpTextBox.
''' </summary>
Overridable Property regex() As String
Get
Return myRegexStr
End Get
Set(ByVal value As String)
If value <"" Then
myRegexStr = value
myRegex = New
System.Text.RegularExpressions.Regex(myRegexStr,
System.Text.RegularExpressions.RegexOptions.Compil ed)
End If
End Set
End Property

''' <summary>
''' This procedure is used to check if this TextBox's text matches
its regular expression.
''' </summary>
''' <remarks>If the match is unsuccessful, then text will not be
updated.</remarks>
Public Overridable Sub match()
Dim myMatch As System.Text.RegularExpressions.Match =
myRegex.Match(Me.Text)
If myMatch.Success Then
myStr = Me.Text
Else
Me.Text = myStr
'MsgBox("You must match: " & myRegexStr,
MsgBoxStyle.Exclamation, "RegexpTextBox")
End If
End Sub

Private Sub regexpTextBox_TextChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles Me.TextChanged
Me.match()
End Sub
End Class

Dec 19 '06 #4
Thank you,

Samuel

<lo*********@gmail.comwrote in message
news:11*********************@79g2000cws.googlegrou ps.com...
>
Samuel Shulman wrote:
>Thanks,

All I found is the MaskedTextBox control and the Mask property which
doesn't
have a mask for email or URL address

Cheers,
Samuel
You can write a class that inherits the MaskedTextbox and uses regular
expressions for validation. It's pretty easy.

Here's an old piece of code I found for doing that:
(It could probably use a bit of work though - I have a newer version,
but not on this computer)
''' <summary>
''' This class is a text box that will make sure that its input only
contains text matching its
''' regular expression.
''' </summary>
''' <remarks>If the user attempts to enter a character that causes the
text to not match the
''' regular expression, then the text will be reverted to what it was
before the user's action.</remarks>
Public Class regexpTextBox
Inherits System.Windows.Forms.TextBox

Protected myRegex As New System.Text.RegularExpressions.Regex(".*",
System.Text.RegularExpressions.RegexOptions.Compil ed)

Protected myRegexStr As String
Protected myStr As String = ""

''' <summary>
''' Gets or sets the string representation of this regexpTextBox.
''' </summary>
Overridable Property regex() As String
Get
Return myRegexStr
End Get
Set(ByVal value As String)
If value <"" Then
myRegexStr = value
myRegex = New
System.Text.RegularExpressions.Regex(myRegexStr,
System.Text.RegularExpressions.RegexOptions.Compil ed)
End If
End Set
End Property

''' <summary>
''' This procedure is used to check if this TextBox's text matches
its regular expression.
''' </summary>
''' <remarks>If the match is unsuccessful, then text will not be
updated.</remarks>
Public Overridable Sub match()
Dim myMatch As System.Text.RegularExpressions.Match =
myRegex.Match(Me.Text)
If myMatch.Success Then
myStr = Me.Text
Else
Me.Text = myStr
'MsgBox("You must match: " & myRegexStr,
MsgBoxStyle.Exclamation, "RegexpTextBox")
End If
End Sub

Private Sub regexpTextBox_TextChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles Me.TextChanged
Me.match()
End Sub
End Class

Dec 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: buran | last post by:
Dear ASP.NET Programmers, I have a web user control (a search menu) which has 2 validation controls (one for input and another for the search criterion). I am including this search user control...
6
by: Nedu N | last post by:
Hi, I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls to be triggered first and then Yes/No...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
6
by: Stephen | last post by:
Hi, the validation controls dont work on Netscape or Mozilla and only on Internet Explorer why? How do i correct this problem? Thanks
2
by: Martyn Fewtrell | last post by:
Dear All I have a Windows 2003 Server with IIS6 where the validation controls on ASP.Net pages no longer work. I believe it to be specific to the server as if I create an ASP.Net page on the...
7
by: Ryan Ternier | last post by:
We're running a site that has required field validation on the login page. It works fine on our development / test machines. However, when I upload this site to our live server i get this error. ...
2
by: Tim Frawley | last post by:
Source code attached indicates my problem with validation and a button bar save button. Fill the Textbox with some text then tab off the control. The message box will display the text in the...
5
by: Kyle | last post by:
On my Development System, all the page validation controls work fine (WinXP Pro + SP2, VS.NET 2003, .NET v1.1.4322). On the Production System, none of the page validation controls are working...
12
by: Dabbler | last post by:
I need to insure that at least one of three phone number fields has a value (requiredfield) but I'm not sure of a way to implement this without server side logic. Is there a way to use the...
0
by: dhurwitz | last post by:
Hi, In my ASP.NET 2.0 web app, I have a user control, ucBinEdges, with several text boxes. The user control has several validation controls validating the Text of these text boxes -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.