FormValidation(表单提交及验证标签)
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<t:formvalid formid="formobj" dialog="false" layout="div" callback="test" tiptype="1" action="jeecgFormvalidController.do"
beforeSubmit="setContentc">
<fieldset class="step">
<div class="form">
<label class="Validform_label"> 非空验证: </label>
<input type="text" name="demotitle" id="demotitle" datatype="*" errormsg="该字段不为空">
<span class="Validform_checktip"></span>
</div>
<div class="form">
<label class="Validform_label"> URL验证: </label>
<input type="text" name="demourl" id="demourl" datatype="url" errormsg="必须是URL">
<span class="Validform_checktip"></span>
</div>
<div class="form">
<label class="Validform_label"> 至少选择2项: </label>
<input name="shoppingsite1" class="rt2" id="shoppingsite21" type="checkbox" value="1" datatype="need2" />阅读
<input name="shoppingsite1" class="rt2" id="shoppingsite22" type="checkbox" value="2" /> 音乐
<input name="shoppingsite1" class="rt2" id="shoppingsite23" type="checkbox" value="3" /> 运动
<span class="Validform_checktip"></span>
</div>
<div class="form" id="mail_id">
<label class="Validform_label"> 邮箱: </label>
<input type="text" name="demoorder" id="demoorder" datatype="e" errormsg="邮箱非法">
<span class="Validform_checktip"></span>
</div>
<div class="form">
<label class="Validform_label"> 手机号: </label>
<input type="text" name="phone" id="phone" datatype="m" errormsg="手机号非法">
<span class="Validform_checktip"></span>
</div>
<div class="form" id="money_id">
<label class="Validform_label"> 金额: </label>
<input type="text" name="money" id="money" datatype="d" errormsg="金额非法">
<span class="Validform_checktip"></span>
</div>
<div class="form">
<label class="Validform_label"> 日期: </label>
<input type="text" name="date" id="date" class="easyui-datebox">
<span class="Validform_checktip"></span>
</div>
<div class="form">
<label class="Validform_label"> 时间: </label>
<input type="text" name="time" id="time" class="easyui-datetimebox">
<span class="Validform_checktip"></span>
</div>
<div class="form">
<label class="Validform_label"> 时间: </label>
<input id="d12" type="text" datatype="*" errormsg="该字段不为空"/>
<img onclick="WdatePicker({el:'d12'})" src="plug-in/easyui/themes/black/images/datebox_arrow.png"
style="opacity: 0.6;height:17px;width:17px;" align="absmiddle">
<span class="Validform_checktip"></span>
</div>
<div style="text-align:center"><input class="btn" type="submit" value="提交"></div>
</fieldset>
</t:formvalid>
<script>
function setContentc(){
alert("表单提交前想干点啥呢");
}
function test(){
alert("表单提交后要干点啥呢");
}
</script>
备注:
1、tiptype:表单校验提示方式,tiptype="1" 表示提示方式为框架自定义弹窗。
2、datatype:控件验证方式。
3、beforeSubmit:提交前调用方法。
4、callback:表单提交完成后的回调函数。
<t:formvalid formid="formobj" dialog="true" layout="div" callback="@Override formCallBack" action="jeecgFormvalidController.do?testsubmit=2" beforeSubmit="setContentc">
<fieldset class="step">
<div class="form">
<label class="Validform_label"> 非空验证: </label>
<input type="text" name="demotitle" id="demotitle" datatype="*" errormsg="该字段不为空">
<span class="Validform_checktip"></span>
</div>
<div style="text-align:center"><input class="btn" type="submit" value="提交" style="height:30px;width:100px !important;border-radius:5px"></div>
</fieldset>
</t:formvalid>
<script type="text/javascript">
function formCallBack(){
var win = frameElement.api.opener;
if (data.success == true) {
frameElement.api.close();
win.tip(data.msg);
} else {
if (data.responseText == '' || data.responseText == undefined) {
$.messager.alert('错误', data.msg);
$.Hidemsg();
} else {
try {
var emsg = data.responseText.substring(data.responseText.indexOf('错误描述'), data.responseText.indexOf('错误信息'));
$.messager.alert('错误', emsg);
$.Hidemsg();
} catch(ex) {
$.messager.alert('错误', data.responseText + "");
$.Hidemsg();
}
}
return false;
}
win.reloadTable();
}
</script>
备注:callback:表单提交完成后的回调函数。如果dialog="true"的话, callback="@Override formCallBack" 调用的是当前页面的方法 , callback="formCallBack" 调用的是父页面的方法;如果dialog="false" ,callback="formCallBack" 调用的是当前页面的方法