| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- $(function () {
- $("#form-content-edit").validate({
-
- rules: {
- title: {
- required: true,
- minlength: 1,
- maxlength: 64
- },
- navigation_id: {
- required: true,
- },
- content: {
- required: true,
- },
- resource: {
- // required: true,
- minlength: 1,
- maxlength: 64
- },
- sort: {
- required: true,
- min: 0,
- max: 10000,
- digits: true
- },
- brief: {
- // // required: true,
- // maxlength: 100
- }
- },
- onkeyup:false,
- focusCleanup:true,
- success:"valid",
- submitHandler:function(form){
- //如果摘要没填写,取正文前50个字
- //2018-07-06 不需要自动加摘要
- /*if($.trim($("#brief").val())==""){
- var content = $("#content").val();
- if($.trim(content)!=""){
- var defaultAbstract = "";
- //去除标签
- var cleanContent = content.replace(/<\/?.+?>/g,""); //去标签
- cleanContent = cleanContent.replace(/(^\s+)|(\s+$)/g,""); //去空格
- cleanContent = cleanContent.replace(/(\r)|(\n)/g,""); //去回车
- cleanContent = cleanContent.replace(/ /ig,''); //去掉
- if(cleanContent.length>50){
- defaultAbstract = cleanContent.substring(0,50);
- defaultAbstract += "...";
-
- }else{
- defaultAbstract = cleanContent;
- }
- $("#brief").val(defaultAbstract);
- }
- }*/
- $(form).ajaxSubmit({
- type: 'PUT',
- url: pagePath+"/government/content/update/"+$("#content_id").val(),
- dataType:"json",
- success: function(data){
- if(data.status == "success"){
- succeedMessage(data.message);
- setTimeClose();
- }else {
- errorMessage(data.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- },
- errorPlacement: function(error, element) {
- if(element.attr('id') == 'content'){
- error.addClass(' label_error')
- }
- error.appendTo(element.parent());
- }
- });
- });
|