js验证出错,急!!!!
<script type="text/javascript">
function checkSubmit() {
if(required('wname') && required('month') && required('day') &&
required('fre','1') && required('num') && required('wbt') &&
required('wet') && required('wbt') && required('wfre','1')){
if(document.myform.warnMode.checked==true){
if(required('sbt') && required('set') && required('mfre','1') && required('incepters')){
return true;
}
return false;
}else{
return true;
}
}
return false;
}
/*
* names:元素ID
* num:如果不为空,则判断是否为数字
*/
function required(names,num){
var va = document.getElementById(names).value;
if(va==''){
document.getElementById(names+"1").innerHTML='必填项';
return false;
}else{
document.getElementById(names+"1").innerHTML='';
}
if(num!='' && num!=null){
var reg = /^\d+$/;
if(!reg.test(va)){
document.getElementById(names+"1").innerHTML+=',只能为数字';
return false;
}
return true;
}
return true;
}
</script>
</head>
<body onload="init();">
<form name="myform" id="myform" action="warnCondition_doAdd.action" method="post" onsubmit="return checkSubmit()">
<table id="mainTable" class="list_table" cellspacing="1"
cellpadding="1">
<tr>
<td colspan="4" class="edit_title">添加预警信息</td>
</tr>
<TR>
<tr>
<td colspan="4" class="edit_title1">基本信息</td>
</tr>
<tr>
<td class=edit_label style="vertical-align: top;" width="150px">预警名称:</td>
<td class=edit_content width="300px"><input type="text" name="condition.warnName" id="wname" onblur="required('wname')" />
<div id="wname1" style="color: red;display:inline">*</div></td>
<td class=edit_label width="150px">预警对象(表名):</td>
<td class="edit_content"><select name="condition.warnObj">
<s:iterator value="modelList" id="modelList">
<option value="<s:property value="configCode"/>">
<s:property value="configName" />
</option>
</s:iterator>
</select></td>
</tr>
<tr>
<TD class=edit_label>预警类型:</TD>
<TD class=edit_content><select name="condition.warnType" >
<option value="1">缺少数据或无数据</option>
</select></TD>
<TD class=edit_label>数据采集频率:</TD>
<TD class=edit_content><select id="s1"
name="condition.gatherFre" onchange="inner()">
<option value="0">月</option>
<option value="1">日</option>
<option value="2">分钟</option>
</select>
<div id="innerText0" style="display: none">
到达时间:<input type='text' readonly id="month"
onfocus="WdatePicker({dateFtm:'yyyy-MM-dd'})" name='month'
size='8' onblur="required('month')"/>
&