วิธีตรวจสอบว่ามีข้อมูลข้อความแบบฟอร์ไม่ว่างเปล่า html

รหัสตัวอย่าง

0
0

จาวาสคริปต์โปรดตรวจสอบว่าข้อมูลว่างเปล่า

<!-- check if any input field in "Form" is empty using JS -->

<script type="text/javascript">
  function validateForm() {
    var a = document.forms["Form"]["answer_a"].value;
    var b = document.forms["Form"]["answer_b"].value;
    if (!a || !b) {
      alert("Please Fill All Required Fields");
      return false;
    }
  }
</script>

<form method="post" name="Form" onsubmit="return validateForm()" action="">
  <input type="text" name="answer_a" value="">
  <input type="password" name="answer_b" value="password">
</form>

ในภาษาอื่นๆ

หน้านี้อยู่ในภาษาอื่นๆ

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................

ดังอยู่ในนี้หมวดหมู่

ดังหน้ากับตัวอย่างอยู่ในหมวดหมู่