jQuery 判断表单中多个 input text 中至少有一个不为空

html:

名称1:<input class="seasoning_name" type="text" name="seasoning_name[]">
名称2:<input class="seasoning_name" type="text" name="seasoning_name[]">
名称3:<input class="seasoning_name" type="text" name="seasoning_name[]"> 

js:

seasoning_name = "";
$(‘.seasoning_name‘).each(function(){

      seasoning_name += $(this).val();
})                   

if(seasoning_name == ""){

      alert("至少填写一项配料!");
      return false;
}
时间: 2024-08-25 18:38:46

jQuery 判断表单中多个 input text 中至少有一个不为空的相关文章

jQuery 判断多个 input checkbox 中至少有一个勾选

html ( 使用 TP 标签 ) : <volist name="health_tag" id="htag"> <input type="checkbox" class="helth_tag" name="health_tag[]" value="{$htag}"/>{$htag} </volist> js: if($("input[cla

jquery判断表单内容是否为空

1 //判断表单数据是否为空 2 var t = $('form').serializeArray(); 3 $.each(t,function(i,item){ 4 if(item['value'] == '') { 5 console.log('信息不可为空') 6 showMsg('信息不可为空') 7 flag = 1; 8 return false 9 } else { 10 flag = 0; 11 } 12 }) 原文地址:https://www.cnblogs.com/11697

Input Text关键字——模拟向一个输入框中输入文字内容

Input Text关键字:模拟向一个输入框中输入文字内容. 该关键字接受2个参数 [ locator | text ]:locator参数指的是定位界面元素的方式,text参数指的是需要输入的内容. ==================================================================================== 示例:打开百度页面,输入“robot framework”,这里采用id的方式来定位界面输入框元素. Open Browser 

form表单中隐藏类型input的使用

<form action="PersonSave.ashx" method="post"> <input type="hidden" name="action" value="{action}"/> <input type="hidden" name="id" value="{id}"/> 姓名:<inpu

jquery获取表单中的数据

????????? ?<form> ????????????? ? <input name="username" type="text"/> ????????????? ? <input name="password" type="password"/> ????????????? ? <input id="submitButton" type="butt

JS如何判断表单中用户选择哪个哪个选项?

HTML代码: <form name="form1" onsubmit="return foo();"> A<input type="radio" name="radioGroup" value="a" /> B<input type="radio" name="radioGroup" value="b" />

生成的随机验证码图片放入input text中

css:  56px是图片的width,57px(图片长度+input的border) #img{  position:absolute; width:56px;margin-left: calc(100% - -57px); bottom:0} html:javascript:GetCodes()是刷新验证码的方法 <div class="field"> <input type="text" id="Verfication"

jQuery formValidator表单验证插件常见有关问题

jQuery formValidator表单验证插件常见问题 如何实现一个控件,根据不同的情况,实现不同的控制? 一个页面上我有几个tab页,如何实现每个Tab页上的控件单独校验? 我采用的页面上文字问题的方式,点提交的时候,有校验未通过的,除了文字提示外,还可以再弹出窗口提示吗? 所有校验通过后,我还要再做别的判断可以吗?我自己的判断没有通过可以中断提交吗? 我有一组的checkbox(radiobutton)如何设置校验? 我有2个表单元素,任意一个元素输入东西就算验证通过,如何写代码?比如

JQuery判断radio是否选中并获取选中值的示例代码

这篇文章主要介绍了JQuery判断radio是否选中并获取选中值的方法,代码很简单,但很实用,需要的朋友可以参考下 其他对radio操作功能,以后在添加.直接上代码,别忘记引用JQuery包 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 <!DOCTYPE html PUBLIC "