1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| //写trim方法 function trim(str){ // 将空格替换为无 str=str.replace(/^(\s|\u00A0)+/,''); // 此处设置空格替换内容 for(var i=str.length-1; i>=0; i--){ if(/\S/.test(str.charAt(i))){ str = str.substring(0,i+1); break; } } return str; }
//调用 function commithandling(){ var suggestion=document.getElementById("suggestion").value; if(trim(suggestion)!=""&& suggestion.length>0){ $.post("/lord/commithandling",{'idea':suggestion},function(data){ if(data==1){ alert("提交意见成功"); document.location.reload();
}else{ alert("处理意见不能为空"); } } } }
|