方式一:類似於一下這種驗證
<script type="text/javascript">
//------------------------------------dml相關操作-----------------------------------------------
var CurID = 1;
var Validator = null;[d1]
var editor_description;
$(function ()
{
$("#infoform").ligerForm();
$.metadata.setType("attr", "validate");
deafultValidate($("#infoform"));
Validator = $("#infoform").validate();
[d2] [d3] $("#title").focus();
});
function f_success() {
$.ligerDialog.closeWaitting();
$.ligerDialog.success("保存成功","",function(button,domobject,buttonindex){
top.frames["TabArticle"].f_reload();
LG.closeCurrentTab('TabArticleModify');
});
}
function f_error(message)
{
$(document).ready(function(){
$.ligerDialog.error(message);
});
}
//按鈕提交
function f_post(){
var nid=$("#nid").val();
var rootid=$("#rootid").val();
var options = {
target:'',
url:'article!save.action?nid='+nid,
type:'POST',
success: function(data,textStatus){
if(data=='false'){
$.ligerDialog.closeWaitting();
$.ligerDialog.error("保存失敗");
}else if(data=='true'){
f_success();
}
}};
$('#infoform').ajaxSubmit(options);
}
function f_save()
{
$("form").ligerForm();
editor_description.sync();
$.ligerDialog.waitting("正在保存中...");
setTimeout(function(){
f_post();
},10);
}
</script>
<style type="text/css">
body{ font-size:12px;padding:20px;}
.l-table-edit {}
.l-table-edit-td{ padding:4px;}
.l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
.l-verify-tip{ left:230px; top:120px;}
</style>
</head>
<body>
<div>
<form id="infoform" action="" method="post" >
<input type="hidden" name="articleid" id="articleid" value="${articleid}"/>
<input type="hidden" id="nid" value="${nid}"/>
<input type="hidden" name="rootid" id="rootid" value="${rootid}"/>
<table cellpadding="0" cellspacing="0" class="l-table-edit" align="left" >
<tr>
<td class="l-table-edit-td">標題:</td>
<td class="l-table-edit-td" colspan="2"><input ligerui="{width:600}" name="title" value="${title}" type="text" id="title"
validate="{required:true,minlength:1,maxlength:50}" [d5] /></td>
<td align="left"><font color="red">*</font></td>
</tr>
<tr>
<td class="l-table-edit-td">摘要:</td>
<td class="l-table-edit-td" style="width:600px" colspan="2">
<textarea cols="100" rows="5" class="l-textarea" id="abstract_" name="abstract_" style="width:600px"
validate="{required:true,minlength:1,maxlength:100}" >${abstract_}</textarea>
</td>
<td align="left"><font color="red">*</font></td>
</tr>
<tr>
<td class="l-table-edit-td" valign="top">首頁顯示</td>
<td class="l-table-edit-td" style="width:160px">
<input id="rbtnl_0" type="radio" name="isnotice" value="1" <c:if test="${isnotice==1}">checked</c:if> /><label for="rbtnl_0">是</label>
<input id="rbtnl_1" type="radio" name="isnotice" value="0" <c:if test="${isnotice==0||isnotice==''}">checked</c:if>/><label for="rbtnl_1">否</label>
</td>
<td class="l-table-edit-td" style="width:160px"></td>
<td align="left"></td>
</tr>
<tr>
<td class="l-table-edit-td">正文:</td>
<td class="l-table-edit-td" colspan="2">
<textarea id="editor_description" name="content" style="width:600px;height:300px;">${content}</textarea>
</td>
<td align="left"></td>
</tr>
</table>
</form>
</div>
<script type="text/javascript">
$(function() {
KindEditor.ready(function(K) {
editor_description = K.create('#editor_description', {
resizeType : 0, //2或1或0,2時可以拖動改變寬度和高度,1時只能改變高度,0時不能拖動。
allowPreviewEmoticons : false,//true時鼠標放在表情上可以預覽表情。
allowImageUpload : false,
items : ['source','fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'table']
});
});
});
LG.setFormDefaultBtn(f_cancel,f_save);
[d6] </script>
</body>
</html>
方式二: