မူလတန်ဖိုး ပြန်ထားရန် Input (type="reset")

HTML Living Standard

Form controls တွေကို စဖွင့်ချိန် တန်ဖိုးအတိုင်း ပြန်ထားပါတယ်။ အသုံးပြုသူက reset လုပ်ချင်တဲ့အခါ သုံးပါ။

ဒီစာမျက်နှာမှာ

Attribute နဲ့ အလုပ်လုပ်ပုံ

တန်ဖိုး သို့မဟုတ် ရေးပုံအလုပ်လုပ်ပုံ
value="Restore"Reset ခလုတ်ပေါ်မှာ ပြမယ့် စာသား ပြောင်းပါတယ်။

နမူနာကို စမ်းကြည့်ပါ

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Reset input</title>
  <style>
form { display: grid; gap: 12px; justify-items: start; } output { display: block; margin-top: 10px; }
  </style>
</head>
<body>
<form id="demo">
  <label>Room <input name="room" value="Room 2"></label>
<input type="reset" value="Restore">
  <button type="submit">Check</button>
</form>
<output id="response"></output>
  <script>
const form = document.querySelector('#demo');
form.addEventListener('click', event => {
  const submitter = event.target.closest('[type="submit"], [type="image"]');
  if (!submitter) return;
  event.preventDefault();
  if (!form.noValidate && !submitter.formNoValidate && !form.reportValidity()) return;
  const values = new FormData(form, submitter);
  document.querySelector('#response').textContent =
    'Passed validation. Fields received: ' + [...values.keys()].join(', ');
});
  </script>
</body>
</html>

စမ်းကြည့်ရင် ဘာဖြစ်မလဲ Room 2 ကို Room 3 ပြောင်းပြီး Restore နှိပ်ပါ။ မူလစာသား ပြန်ပေါ်ပါမယ်။

တရားဝင် ကိုးကားချက်များ