You must Sign In to post a response.
  • Category: JavaScript

    How to validate email

    dinesh5@gm.com like this when iam entering i want to show
    in correct mail how to do this
  • #758814
    Hello Dinesh Kumar,

    Below is simple regular expression to validate an email address. It will accept email address in upper case also:
    <script type="text/javascript">
    function validateEmail(email)
    {
    var reg = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
    if (reg.test(email)){
    return true; }
    else{
    return false;
    }
    }
    </script>

    Below is regular expression to validate an email address with lower case chars:
    <script type="text/javascript">
    function validateCaseSensitiveEmail(email)
    {
    var reg = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
    if (reg.test(email)){
    return true;
    }
    else{
    return false;
    }
    }
    </script>

    Below is regular expression to validate domain specific email address:
    <script type="text/javascript">
    function validateFreeEmail(email)
    {
    var reg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$/
    if (reg.test(email)){
    return true;
    }
    else{
    return false;
    }
    }
    </script>

    Hope this will help you.
    Mark the answer if it helped you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #758820
    Hi Dineshkumar.

    To validate email you have many regular expressions based on your requirement.

    You can validate email with alphabets,numbers and upper case lower case or with only specified domains.

    Following regular expression will match your requirement to validate domain specific.

    var reg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)
    (?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$/

    Regards

    Sridhar.
    DNS Member.
    "Hope for the best.. Prepare for the worst.."

    Sridhar Thota.
    Editor: DNS Forum.

  • #758870
    Hi,

    Visit the below given link:

    http://www.articlemirror.in/2013/06/how-to-validate-email-in-aspnet-using.html

    Thanks,
    Vijay Saklani

  • #760824
    Hi
    Vijay

    your code based on Database . If the records is database means validate them

    User asking based on domain based

    if it is any possible for checking email id have r not.

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762999
    You can try this.

    var $email = $('form input[name="email'); //change form to id or containment selector
    var re = /^(([^<>()[]\.,;:s@"]+(.[^<>()[]\.,;:s@"]+)*)|(
    ".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA
    -Z-0-9]+.)+[a-zA-Z]{2,}))$/igm;
    if ($email.val() == '' || !re.test($email.val()))
    {
    alert('Please enter a valid email address.');
    return false;
    }

    Hope this helps.


  • Sign In to post your comments