August 29, 2013

Verifying Email address

Liondancer’s Question:

I’m trying to create a form that verifies that an email address has been entered. Not necessarily check its validity but basically I was wondering how to go about doing it in PURE JavaScript and no RegEx.

    <!DOCTYPE html>

    <html lang="en" xmlns="">
        <meta charset="utf-8" />
        <title>Test File</title>
            function submitForms() {
                email_format = document.getElementById('email_input')       // want to return T or F
                if (email_format) {
                    //print email successful
                else {
                   //print error message


            <input type ="email" id ="email_input" />

        <button type = "button" onclick = "submitForms;"> Submit All!

Here is a previously answered regular expression answer. Its pretty good.

function validateEmail(email) { 
    var re = /^(([^<>()[]\.,;:s@"]+(.[^<>()[]\.,;:s@"]+)*)|(
    return re.test(email);


However, the only good to verify an email address is by sending a confirmation email and hearing back.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+


Please fill the form - I will response as fast as I can!