Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang='en'>
- <head>
- <meta charset='utf-8'>
- <title>js test</title>
- </head>
- <body>
- <input type='text' id='email'/>
- <p id='notice'></p>
- <script type='text/javascript'>
- (function() {
- var
- is_email=/^[\w\.%+-]+@[a-z0-9\.-]+\.[a-z]{2,4}$/i,
- email =document.getElementById('email'),
- notice =document.getElementById('notice');
- function isValidEmail(txt) {
- return !!txt.match(is_email);
- }
- function updateAlert(e) {
- if(isValidEmail(email.value))
- notice.innerHTML='';
- else
- notice.innerHTML='Not a valid email address.';
- }
- email.addEventListener('keyup',updateAlert);
- updateAlert();
- })();
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment