www.webdeveloper.com
Results 1 to 2 of 2

Thread: simple email validation BUT how to validate with gmail

  1. #1
    Join Date
    Mar 2012
    Posts
    23

    simple email validation BUT how to validate with gmail

    hi there,

    have these simple code for email validation but I am stuck as I want to predefine gmail emails to give ex discount...

    here is the code:

    Code:
    <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Check Email Address</title>
    <script language="javascript">
    function checkEmail(inputvalue){
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){
    alert("true");
    }else{
    alert("false");
    }
    }
    </script>
    </head><body>
    <form name="signupform">
    Input your email: <input name="email" type="text" class="inputs" id="email_address"
    value="any@any.com" size="35" maxlength="255">
    <input name="summit" type="submit" value="Check" onClick="checkEmail(document.signupform.email.value)">
    </form></body></html>
    but when i change that code to recognize gmail
    Code:
    <script language="javascript">
    function checkEmail(inputvalue){
    var pattern=/^([a-zA-Z0-9_.-])+@(gmail])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){
    alert("true");
    }else{
    alert("false");
    }
    }
    </script>
    only gmail accounts are valid
    any chance to implement @(gmail]) & @([a-zA-Z0-9_.-]) ?

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,674
    if(inputvalue.indexOf('@gmail.')==-1){alert('NO WAY!');}

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles