Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何最好地将客户端验证添加到这两个字段_Javascript_Html_Forms - Fatal编程技术网

Javascript 如何最好地将客户端验证添加到这两个字段

Javascript 如何最好地将客户端验证添加到这两个字段,javascript,html,forms,Javascript,Html,Forms,当用户选择“您的浸信会健康体验”时。如何最好地为“姓名和联系信息”输入字段应用客户端验证 <ul class="textinput reason gridA"> <li><p class="feedback"><label><input runat="server" type="radio" name="feedbackreason[]" aria-label="What would you like to tell us about?"

当用户选择“您的浸信会健康体验”时。如何最好地为“姓名和联系信息”输入字段应用客户端验证

<ul class="textinput reason gridA">
  <li><p class="feedback"><label><input runat="server" type="radio" name="feedbackreason[]" aria-label="What would you like to tell us about?" aria-valuetext="Your Baptist Health experience" title="What would you like to tell us about?: Your Baptist Health experience" id="bhexperience"  class="feedbackreason reqType" value="bd" clientidmode="Static" /> Your Baptist Health experience</label></p></li>
  <li class="block panel-content marginT20">
      <div class="hidePanel" style="display:none">
      <p class="hl4">To enable us to respond to your comments, would you please let us know who to contact?</p>
      <p class="marginT10 marginL10"><label for="feedbackName" class="alignL">Name:</label><input type="text" name="feedbackName" id="feedbackName" class="text feedbackName marginL5" title="feedback Name" /><br />
      <br />
      <label for="contactInfo" class="alignL">Contact Information:</label><input type="text" name="contactInfo" id="contactInfo" class="text contactInfo marginL5" title="Contact Information" /></p>
      <p class="hl4 marginT10">For immediate patient portal service, please call
      <br />
      <strong><a class="phoneCall" style="color: mediumvioletred" href="tel:18446220622">1.844.622.0622</a></strong> (toll-free, 24/7)</p>       
      </div>
  </li>
</ul>
  • 您的浸信会健康体验

  • 为了让我们能够对您的评论作出回应,请您告知我们联系谁好吗

    名称:

    联系方式:

    有关即时患者门户服务,请致电
    (免费,24/7)


在要强制用户填写的输入元素中添加了required

<ul class="textinput reason gridA">
  <li>
    <p class="feedback">
      <label>
        <input runat="server" type="radio" name="feedbackreason[]" aria-label="What would you like to tell us about?" aria-valuetext="Your Baptist Health experience" title="What would you like to tell us about?: Your Baptist Health experience" id="bhexperience"
        class="feedbackreason reqType" value="bd" clientidmode="Static" /> Your Baptist Health experience</label>
    </p>
  </li>
  <li class="block panel-content marginT20">
    <div class="hidePanel" style="">
      <p class="hl4">To enable us to respond to your comments, would you please let us know who to contact?</p>
      <p class="marginT10 marginL10">
        <label for="feedbackName" class="alignL">Name:</label>
        <input type="text" name="feedbackName" id="feedbackName" class="text feedbackName marginL5" title="feedback Name" required>
        <br />
        <br />
        <label for="contactInfo" class="alignL">Contact Information:</label>
        <input type="text" name="contactInfo" id="contactInfo" class="text contactInfo marginL5" title="Contact Information" required>
      </p>
      <p class="hl4 marginT10">For immediate patient portal service, please call
        <br />
        <strong><a class="phoneCall" style="color: mediumvioletred" href="tel:18446220622">1.844.622.0622</a></strong> (toll-free, 24/7)</p>
    </div>
  </li>
</ul>
  • 你的浸信会健康经历

  • 为了让我们能够对您的评论作出回应,请您告知我们联系谁好吗

    姓名:

    联系方式:

    有关即时患者门户服务,请致电
    (24/7免费)


只是试图要求用户输入一个名称。你想验证什么?我已经设置了这个JSFIDLE