Answered by:
how to call a function for validating a textbox?

Question
-
hi
i have this function to validate my textbox (the code below), but how am i going to call this function.
the result i want is when i key in the textbox and the value in the textbox doesnt match, it show prompt a message on a label beside the textbox, unless the value change to the correct one then the user can click on the button
the question is where should i call the function in the aspx.vb and how?
Public Function vldEmail(ByVal emlAddress As String) As Boolean ‘create Regular Expression Match pattern object Dim myRegex As New Regex("^([a-zA-Z0-9_\-\.]+)@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$") ‘boolean variable to hold the status Dim isValid As Boolean = False If emlAddress = "" Then isValid = False Else isValid = myRegex.IsMatch(emlAddress) End If ‘return the results Return isValid End Function
- Moved by Mike Feng Wednesday, November 30, 2011 3:40 AM ASP.net (From:Visual Basic General)
Monday, November 28, 2011 3:04 PM
Answers
-
Sorry, I didn't notice that you were using ASP.NET. Since the behavior is different in Windows Forms, I would recommend posting to the ASP.NET forum:
Paul ~~~~ Microsoft MVP (Visual Basic)- Proposed as answer by Mike Feng Wednesday, November 30, 2011 3:39 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Friday, December 9, 2011 7:08 AM
Monday, November 28, 2011 3:43 PM
All replies
-
Will the RegularExpressionValidater control work for you?
http://msdn.microsoft.com/en-us/library/eahwtc9e.aspx
Monday, November 28, 2011 3:35 PM -
Will the RegularExpressionValidater control work for you?
http://msdn.microsoft.com/en-us/library/eahwtc9e.aspx
yes this work, but if code a function for the textbox validation from aspx.vb like what you see at above, how am i goin to call to achieve similar result as regular expression validator?
Monday, November 28, 2011 3:39 PM -
You can use the Validating Event to handle the validation:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.validating.aspx
Paul ~~~~ Microsoft MVP (Visual Basic)- Proposed as answer by Crazypennie Monday, November 28, 2011 3:42 PM
Monday, November 28, 2011 3:40 PM -
You can use the Validating Event to handle the validation:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.validating.aspx
Paul ~~~~ Microsoft MVP (Visual Basic)Monday, November 28, 2011 3:42 PM -
Sorry, I didn't notice that you were using ASP.NET. Since the behavior is different in Windows Forms, I would recommend posting to the ASP.NET forum:
Paul ~~~~ Microsoft MVP (Visual Basic)- Proposed as answer by Mike Feng Wednesday, November 30, 2011 3:39 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Friday, December 9, 2011 7:08 AM
Monday, November 28, 2011 3:43 PM