blur
RUN
<!DOCTYPE html> <html> <head> <title>jQuery Example</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="https://code.jquery.com/jquery-3.0.0.js"></script> <script> $(document).ready(function () { $("#username").blur(function () { var value = $(this).val(); if (value === ''){ alert("Vui lòng nhập username"); } }); $("#password").blur(function () { var value = $(this).val(); if (value === ''){ alert("Vui lòng nhập password"); } }); }); </script> </head> <body> <form> <input id="username" type="text" value="" placeholder="Username"> <br/><br/> <input id="password" type="password" value="" placeholder="Password"> <br/><br/> <input type="text" value="LOGIN"> </form> </body> </html>
PHÓNG TO