Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE HTML> <html> <head> <title>Title of the Document</title> <style> .errorClass { border-color: red; } </style> </head> <body> <div> Your email please: <input type="email" id="input"> <input type="text" placeholder="invalidate the email and try to focus here"> </div> <script> input.onblur = function() { if(!this.value.includes('@')) { // not email // show the error this.classList.add("errorClass"); // ...and put the focus back input.focus(); } else { this.classList.remove("errorClass"); } }; </script> </body> </html>