Results 1 to 3 of 3

Thread: Validation script for Email Id

  1. #1
    Join Date
    Jan 2009
    Posts
    576

    Validation script for Email Id

    i need java script to validate email account .as when I enter one email address for which , i have to validate the mail id, i am unable to validate.so please some one can help me to do this thing ?

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Validation script for Email Id

    <script language = "Javascript">

    function echeck(str) {

    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
    if (str.indexOf(at)==-1){
    alert("Invalid E-mail ID")
    return false
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    alert("Invalid E-mail ID")
    return false
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    alert("Invalid E-mail ID")
    return false
    }

    if (str.indexOf(at,(lat+1))!=-1){
    alert("Invalid E-mail ID")
    return false
    }

    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    alert("Invalid E-mail ID")
    return false
    }

    if (str.indexOf(dot,(lat+2))==-1){
    alert("Invalid E-mail ID")
    return false
    }

    if (str.indexOf(" ")!=-1){
    alert("Invalid E-mail ID")
    return false
    }

    return true
    }

    function ValidateForm(){
    var emailID=document.frmSample.txtEmail

    if ((emailID.value==null)||(emailID.value=="")){
    alert("Please Enter your Email ID")
    emailID.focus()
    return false
    }
    if (echeck(emailID.value)==false){
    emailID.value=""
    emailID.focus()
    return false
    }
    return true
    }
    </script>

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Validation script for Email Id

    function validateEmail(strEmail)

    {



    var at="@"

    var dot="."

    var lat=strEmail.indexOf(at)

    var lstr=strEmail.length var

    ldot=strEmail.indexOf(dot)

    if (strEmail.indexOf(at)==-1)

    {

    alert("Invalid E-mail ID")

    return false

    }

    if (strEmail.indexOf(at)==-1 || strEmail.indexOf(at)==0 || strEmail.indexOf(at)==lstr)

    {

    alert("Invalid E-mail ID")

    return false

    }

    if (strEmail.indexOf(dot)==-1 || str.indexOf(dot)==0 || strEmail.indexOf(dot)==lstr)

    {

    alert("Invalid E-mail ID")

    return false

    }

    if (strEmail.indexOf(at,(lat+1))!=-1)

    {

    alert("Invalid E-mail ID")

    return false

    }

    if (strEmail.substring(lat-1,lat)==dot || strEmail.substring(lat+1,lat+2)==dot)

    {

    alert("Invalid E-mail ID")

    return false

    }

    if (strEmail.indexOf(dot,(lat+2))==-1)

    {

    alert("Invalid E-mail ID")

    return false

    }

    if (strEmail.indexOf(" ")!=-1)

    {

    alert("Invalid E-mail ID")

    return false

    }

    return true

    }

Similar Threads

  1. Replies: 3
    Last Post: 14-01-2014, 09:38 AM
  2. Cannot compose an email as getting script errors
    By Aanand in forum Windows Software
    Replies: 6
    Last Post: 20-08-2010, 11:11 AM
  3. Word 2008 + bibfuse: no script in script menu
    By deval4u in forum Software Development
    Replies: 5
    Last Post: 06-04-2009, 12:53 PM
  4. Replies: 2
    Last Post: 14-01-2009, 01:25 PM
  5. Replies: 4
    Last Post: 07-03-2008, 07:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,520,833.37852 seconds with 16 queries