FormData.entries()未捕获单选框字段的问题求助
FormData.entries()未捕获单选框字段的问题求助
各位好,我在做表单验证的时候,通过遍历FormData.entries()来处理字段,但发现其中的单选框字段没有被捕获到,实在搞不明白哪里出问题了,来求助大家!
我是这么初始化循环的,还加了日志输出:
for (let [fieldName, val] of formData.entries()) { console.log(fieldName); }
控制台输出的字段如下:
name email property deliveryAddr startDate duration other
我原本预期deliveryCity会紧跟在deliveryAddr后面出现,但实际完全没看到。下面是包含这两个字段的HTML代码块(用到了Bulma的样式类):
我一开始以为是单选框没加value属性,加上之后还是没解决问题,deliveryCity依然没出现在FormData.entries()里。麻烦大家帮忙看看,谢谢啦!
<div class="mt-2 is-hidden abc-contact-form-delivery-required-fields"> <div class="field"> <label class="label is-size-4"> <span class="mr-1 has-text-primary-dark">Delivery Street Address</span> <span class="has-text-danger">*</span> </label> <div class="control has-icons-left has-icons-right abc-featured-property-label"> <input class="input" type="text" class="abc-contact-form-field-delivery-addr" name="deliveryAddr" placeholder="Your Beach Home Address"> <span class="icon is-small is-left"> <i class="fas fa-road"></i> </span> </div> </div> <div> <label class="label is-size-4"> <span class="mr-1 has-text-primary-dark">Delivery City</span> <span class="has-text-danger">*</span> </label> <div class="mb-3 abc-featured-property-label">Sorry we do not deliver to Fort Morgan</div> <div class="field abc-featured-property-label"> <div class="control"> <label class="radio is-size-5"> <input type="radio" name="delivery-city" value="Orange Beach" class="abc-contact-form-field-delivery-city"> Orange Beach </label> <label class="radio is-size-5"> <input type="radio" name="delivery-city" value="Gulf Shores" class="abc-contact-form-field-delivery-city"> Gulf Shores </label> </div> </div> </div> </div>
备注:内容来源于stack exchange,提问作者Dexygen
相关产品推荐
相关产品推荐

