daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html lang='en'>
  3.     <head>
  4.         <meta charset='utf-8'>
  5.         <title>email validator example</title>
  6.     </head>
  7.     <body>
  8.         <input type='text' id='email'/>
  9.         <p id='notice'></p>
  10.         <script type='text/javascript'>
  11.             (function() {
  12.                 var
  13.                     is_email=/^[\w\.%+-]+@[a-z0-9\.-]+\.[a-z]{2,4}$/i,
  14.                     email   =document.getElementById('email'),
  15.                     notice  =document.getElementById('notice');
  16.  
  17.                 function isValidEmail(txt) {
  18.                     return !!txt.match(is_email);
  19.                 }
  20.                 function updateAlert(e) {
  21.                     if(isValidEmail(email.value))
  22.                         notice.innerHTML='';
  23.                     else
  24.                         notice.innerHTML='Not a valid email address.';
  25.                 }
  26.  
  27.                 email.addEventListener('keyup',updateAlert);
  28.                 updateAlert();
  29.             })();
  30.         </script>
  31.     </body>
  32. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top