Email validation and javascript

hi all,

i would like to use the error provider to check whether the input email is in valid type.....this is my code

txtEmail.Text <> "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Then
epModifyMerchant.SetError(txtEmail, "Invalid email type")

but this error occur even we input the valid email address.....

and the other problem is it possible for us to add a javascript in visual basic project.......i wanna pop up a 'confirm message' when the user click on the delete button....

pls provide me the solution if anyone know how to saolve this problems..

thanks



Answer this question

Email validation and javascript

  • ERK

    Hi,
    I think you are talking about ASP.Net Project using Vb.net.
    If so then...

    Solution 1
    Tto validate email address for a textbox put a expression validator set its ControlToValidate property to text box for which validation is required and from its ValidationExpression select Internet Email Address.

    Solution 2
    If you want to show javascript confirm message on server sided button control click event then write following code at page load...

    btnDelete.Attributes.Add("onclick", "return Del();");

    Now what you have to do is declare a javascript button in HTML of you page.

    <script language="javascript">

    function Del()

    {

    if (confirm("Are you sure to want to delete "))

    { return true; }

    else
    { return false; }

    }

    </script>

    Hope this help.



  • larla

    hi ReneeC

    i replace my confirm message by using 'MagBox' in visual basic........

    may i know what javascript functions that u want to include in your project


  • Engage

    thanks Mubshir Raza Ali

    the javascript problem i solved it by using other method already......but how can i check the email input by the user whether it is in valid type......txtEmail.Text <> "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

    but this is not a correct way to do it........(this is what i did in vb.net).... but now i wanna check it in visual basic....is there any possible way to check it

    thanks


  • cdalglish

    is it possible for us to add a javascript in visual basic project.......

    Not in VBE.

    The paid for products have the Visual Web Designer built in so you can do web projects including javascript. You can still do a web project by down loading Visual Web developer. I believe that's still free.



  • ATS.NET

    thanks for ur help, Mubshir Raza Ali

    i found another solution which is easier to use.....below is the sample solution for email validation

    Regex.IsMatch(txtEmail.Text, _
    "^([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})(\] )$") = False Then

    epModifyMerchant.SetError(txtEmail, "Invalid email type")

    thanks


  • Johannes7060

    Hi,

    Ok here is email validation in VB6

    Public Function IsEmail(argEmail As String) As Boolean
    Dim tabemail() As String
    Dim tabprovider() As String

    IsEmail = False

    If InStr(1, argEmail, " ", vbTextCompare) = 0 Then
    tabemail = Split(argEmail, "@")
    If UBound(tabemail) = 1 Then
    tabprovider = Split(tabemail(1), ".")
    If UBound(tabprovider) > 0 Then
    If Len(tabprovider(UBound(tabprovider))) >= 2 Then IsEmail = True
    End If
    End If
    End If
    End Function

    You can find details here!

    Hope this help



  • Email validation and javascript