第一,循环显示“资金类型”的单选结果集
<s:iterator value=”#request.ziJinLeiXing” id=”ziJinLeiXing” >
<input type=”radio” class=”easyui-validatebox” name=”fdipXiangMuQueryBean.ziJinLeiXing” required=”true”
value=”<s:property value=’#ziJinLeiXing.dictionaryCode’/>” <s:if test=”#fdip.ziJinLeiXing==#ziJinLeiXing.name”>checked=”checked”</s:if> /><s:property value=’#ziJinLeiXing.name’/>
</s:iterator><label style=”color: red;”> <b>*</b></label>
第二,js判断资金类型是否被选中
//资金类型
var ziJinLeiXing=$(“input[name=’fdipXiangMuQueryBean.ziJinLeiXing’]:checked”).val();
if(ziJinLeiXing==”” || typeof(ziJinLeiXing)==”undefined”){
$.messager.alert(“提示信息”, “请选择资金类型”);
return false;
}
第三,普及typeof 运算符
返回一个用来表示表达式的数据类型的字符串。
说明
typeof 运算符把类型信息当作字符串返回。typeof 返回值有六种可能: “number,” “string,” “boolean,” “object,” “function,” 和 “undefined.”
typeof 语法中的圆括号是可选项
在js里用到数组,比如 多个名字相同的input, 若是动态生成的, 提交时就需要判断其是否是数组.if(document.mylist.length != “undefined” ) {} 这个用法有误.
正确的是 if( typeof(document.mylist.length) != “undefined” ) {}
或 if( !isNaN(document.mylist.length) ) {}
typeof的运算数未定义,返回的就是 “undefined”.
运算数为数字 typeof(x) = “number”
字符串 typeof(x) = “string”
布尔值 typeof(x) = “boolean”
对象,数组和null typeof(x) = “object”
函数 typeof(x) = “function