需要文本字段

发布于 2025-02-06 19:38:28 字数 1701 浏览 0 评论 0原文

我想从一组文本字段中要求我的文本字段,以便如果填充任何文本字段,则表格将提交

<div class="row">
  <div class="border border-dark d-flex">
    <p class="d-inline ps-1">l.</p>
    <p class="d-inline ps-4">Certified copy of OVD or equivalent e-document of OVD or OVD obtained through digital KYC process needs to be submitted (any one of the following OVDs)</p>
  </div>
</div>
<div class="row">
  <div class="border border-dark col-md-6 ps-4">
    <input type="checkbox" name="OVD" class="check d-inline" required>
    <h4 class="d-inline">A. Passport Number</h4>
  </div>
  <div class="border border-dark col-md-6">
    <input type="text" class="input form-control border-0" name="ovd">
  </div>
</div>
<div class="row">
  <div class="border border-dark col-md-6 ps-4">
    <input type="checkbox" name="OVD" class="check d-inline" required>
    <h4 class="d-inline">B. Voter ID Card</h4>
  </div>
  <div class="border border-dark col-md-6">
    <input type="text" class="input form-control border-0" name="ovd">
  </div>
</div>
<div class="row">
  <div class="border border-dark col-md-6 ps-4">
    <input type="checkbox" name="OVD" class="check d-inline" required>
    <h4 class="d-inline">C. Driving Licence</h4>
  </div>
  <div class="border border-dark col-md-6">
    <input type="text" class="input form-control border-0" name="ovd">
  </div>
</div>
<input type="submit">

我希望我的表格如果填补了任何字段

I want to make my text field required from a group of text field so that if any one is filled then the form will submit

<div class="row">
  <div class="border border-dark d-flex">
    <p class="d-inline ps-1">l.</p>
    <p class="d-inline ps-4">Certified copy of OVD or equivalent e-document of OVD or OVD obtained through digital KYC process needs to be submitted (any one of the following OVDs)</p>
  </div>
</div>
<div class="row">
  <div class="border border-dark col-md-6 ps-4">
    <input type="checkbox" name="OVD" class="check d-inline" required>
    <h4 class="d-inline">A. Passport Number</h4>
  </div>
  <div class="border border-dark col-md-6">
    <input type="text" class="input form-control border-0" name="ovd">
  </div>
</div>
<div class="row">
  <div class="border border-dark col-md-6 ps-4">
    <input type="checkbox" name="OVD" class="check d-inline" required>
    <h4 class="d-inline">B. Voter ID Card</h4>
  </div>
  <div class="border border-dark col-md-6">
    <input type="text" class="input form-control border-0" name="ovd">
  </div>
</div>
<div class="row">
  <div class="border border-dark col-md-6 ps-4">
    <input type="checkbox" name="OVD" class="check d-inline" required>
    <h4 class="d-inline">C. Driving Licence</h4>
  </div>
  <div class="border border-dark col-md-6">
    <input type="text" class="input form-control border-0" name="ovd">
  </div>
</div>
<input type="submit">

i want my form will submit if any of the field filled

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丑丑阿 2025-02-13 19:38:28

您可以从输入元素中删除“必需”。

您将不再使用 type =“ submit” ,而需要使用

  <button type="submit" onClick="check()"> Send </button>

,而是需要创建一些JavaScript函数,以检查是否填充任何输入字段,类似这样的内容:

<script>
 //first you need to take input fields inside variables
 var passportNumber = document.getElementsByName("OVD")[0].value; //cos it returns a list
 var IDcard = document.getElementsByName("ovd")[0].value; //like this for each field
 function check(){
  if(passportNumber || IDcard) //if ANY element has a value       
     return true;      
   else
     return false;
  }
</script> 

注意:如果您是初学者,则可以在HTML Element 中添加此代码,但更好的练习是创建外部JS文件,然后调用它。

You can remove "required" from your input elements.

Instead of going with type="submit" , you will need to go with

  <button type="submit" onClick="check()"> Send </button>

Now, you will need to create some javascript function that checks if any of the input fields are filled, something like this:

<script>
 //first you need to take input fields inside variables
 var passportNumber = document.getElementsByName("OVD")[0].value; //cos it returns a list
 var IDcard = document.getElementsByName("ovd")[0].value; //like this for each field
 function check(){
  if(passportNumber || IDcard) //if ANY element has a value       
     return true;      
   else
     return false;
  }
</script> 

Note: If you are beginner, you can add this code inside of Head HTML element, but better practice is to create an external JS file, and then call it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文