Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Cách sử dụng sự kiện onreset trong JavaScript?

Sự kiện onreset kích hoạt khi form bị reset (nhấn nút type="reset").

Ví dụ

<!DOCTYPE html>
<html>
  <body>
    <script>
      function resetFunct() { alert("Form đã được reset"); }
    </script>
    <form onreset="resetFunct()">
      Nhập tuổi: <input type="number"><br>
      Nhập tháng sinh: <input type="text"><br>
      <input type="reset">
    </form>
  </body>
</html>