Way2tutorial Snippet Editor
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Validation - JavaScript Introduction</title> </head> <body> <form> <input type="text" id="uname" name="uname" placeholder="Your name min 5 char..." /> <button type="button" onclick="if(document.getElementById('uname').value.length < 5){ document.getElementById('uname').style.border = '1px solid #FF0000'; alert('Enter at least 5 character!'); } else { document.getElementById('uname').style.border = '1px solid #41B353'; alert('You entered more then 5 character!'); }">Submit</button> </form> </body> </html>