JS DOM: input email field 📧

By Xah Lee. Date: . Last updated: .

This is for user to input a email address.

Email Address Input Example

Result:

Code

<div>
<label for="email_CKNFV">email address:</label>
<input type="email" id="email_CKNFV" placeholder="psrndzyq@gmail.com" />

<p>Result:
<span id="output_mgD4h"></span></p>
</div>
"use strict";
{
    const email_CKNFV = document.getElementById("email_CKNFV");
    if (email_CKNFV === null)
        throw new Error("id email_CKNFV missing");
    const output_mgD4h = document.getElementById("output_mgD4h");
    if (output_mgD4h === null)
        throw new Error("id output_mgD4h missing");
    const f_update = () => {
        output_mgD4h.textContent = email_CKNFV.value;
    };
    email_CKNFV.addEventListener("input", f_update);
}