hàm xử lý sự kiện
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 () { $("#loginbtn").click(function () { var username = $('#username').val(); var password = $('#password').val(); if (username == "" || password == ""){ alert("Vui lòng nhập đầy đủ thông tin"); return false; } else { alert("Thông tin hợp lệ"); return true; } }); }); </script> </head> <body> <form method="post"> <input id="username" type="text" value="" placeholder="Username"> <br/><br/> <input id="password" type="password" value="" placeholder="Password"> <br/><br/> <input type="submit" value="LOGIN" id="loginbtn"> </form> </body> </html>
PHÓNG TO