locked
how to call a function for validating a textbox? RRS feed

  • 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:

    http://forums.asp.net/

     


    Paul ~~~~ Microsoft MVP (Visual Basic)
    Monday, November 28, 2011 3:43 PM

All replies