Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 电子邮件验证功能不支持';t work | VB.net_Html_Asp.net_Vb.net - Fatal编程技术网

Html 电子邮件验证功能不支持';t work | VB.net

Html 电子邮件验证功能不支持';t work | VB.net,html,asp.net,vb.net,Html,Asp.net,Vb.net,当按下submit按钮时,该函数表示电子邮件格式为false。它将发送有效的电子邮件,即使它不是。我做错了什么?试试这个。无需使用emailAddressMatch Protected Sub btn_Submit_Click(sender As Object, e As EventArgs) Handles btn_Submit.Click Dim _lblresponse As Label = Nothing _lblresponse = New Label Dim

当按下submit按钮时,该函数表示电子邮件格式为false。它将发送有效的电子邮件,即使它不是。我做错了什么?

试试这个。无需使用
emailAddressMatch

Protected Sub btn_Submit_Click(sender As Object, e As EventArgs) Handles btn_Submit.Click
    Dim _lblresponse As Label = Nothing
    _lblresponse = New Label

    Dim MyEmail As String = txb_Email.Text
    If EmailCheck(MyEmail) = True Then
        Dim _lblresponse_Valid As Label = Nothing
        _lblresponse = New Label
    Else
        Dim _lblresponse_Invalid As Label = Nothing
        _lblresponse = New Label
        _lblresponse.Text = "This is not a Valid Email"
        Me.plh_Response_Invalid.Controls.Add(_lblresponse)
    End If

    _lblresponse.Text = "*Your Request Has Been Sent"
    Me.plh_Response.Controls.Add(_lblresponse)




Function EmailCheck(ByVal emailAddress As String) As Boolean


    Dim pattern As String = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
    Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)


    If emailAddressMatch.Success Then
        Return True
    Else
        Return False
    End If

End Function
而不是

If Regex.IsMatch(emailAddress, pattern) then
  return true
Else
  return false
End If

它现在知道电子邮件无效,因为无论是“真”还是“假”,都会出现正确的标签。但是不管怎样,提交按钮仍然有效,并且发送虚假电子邮件。这可能与提交按钮有关吗??
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)