<div id="dialog-form" title="添加">
</br>
<form name="example" id="example" action="${pageContext.request.contextPath}/excavation/addNotice.wz?title="+title+"&contents="+contents method="post">
<fieldset>
公告标题:
<input type="text" style="width:300px" id="title" name="title" >
<br></br>
<label>公告内容:</label>
<br></br>
<textarea id="contents" name="contents" style="width:100%;height:240px;"></textarea>
</fieldset>
</form>
</div>
script:
$(function() {
var t = $( "#title" );
var c = $( "#contents" );
var allFields = $( [] ).add( t ).add( c );
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 450,
width: 750,
modal: true,
open : function(event, ui) {
// 打开Dialog后创建编辑器
KindEditor.create('textarea[name="contents"]', {
resizeType : 1
});
},
buttons: {
"确定": function() {
allFields.removeClass( "ui-state-error" );
var title = t.val();
var contents = c.val();
if(title==""){
alert("公告标题不能为空,请重新输入!")
return false;
}
alert(title);
alert(contents);
$('#example').submit();
$( this ).dialog( "close" );
},
"关闭": function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});