floor_add.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. $(function () {
  2. $("#form-floor-add").validate({
  3. rules:{
  4. build_number:{
  5. required:true,
  6. minlength:1,
  7. maxlength:50
  8. },
  9. 'floorList[0].area': {
  10. isFloat2:true
  11. },
  12. 'floorList[0].pay': {
  13. isFloat2:true
  14. }
  15. },
  16. onkeyup:false,
  17. focusCleanup:false,
  18. success:"valid",
  19. submitHandler:function(form){
  20. // $(form).find(":submit").attr("disabled", true);
  21. $(form).ajaxSubmit({
  22. type: 'post',
  23. url: pagePath+"/build/floor/saveBuilding",
  24. dataType:"json",
  25. success: function(data){
  26. if(data.success){
  27. succeedMessage(data.message);
  28. setTimeClose();
  29. }else {
  30. // $(form).find(":submit").attr("disabled", false);
  31. errorMessage(data.message);
  32. }
  33. },
  34. error: function () {
  35. errorMessage('系统错误!');
  36. }
  37. });
  38. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  39. },
  40. // errorPlacement: function(error, element) {
  41. // if( element.attr('id') == 'floorList[0].floor'
  42. // || element.attr('id') == 'floorList[0].area'
  43. // || element.attr('id') == 'floorList[0].pay'
  44. // ){
  45. // error.addClass(' label_error')
  46. // }
  47. // error.appendTo(element.parent());
  48. // }
  49. });
  50. });
  51. $("#form-floor-edit").validate({
  52. rules:{
  53. build_number:{
  54. required:true,
  55. minlength:1,
  56. maxlength:5
  57. },
  58. 'floorList[0].area': {
  59. isFloat2:true
  60. },
  61. 'floorList[0].pay': {
  62. isFloat2:true
  63. }
  64. },
  65. onkeyup:false,
  66. focusCleanup:true,
  67. success:"valid",
  68. submitHandler:function(form){
  69. // $(form).find(":submit").attr("disabled", true);
  70. $(form).ajaxSubmit({
  71. type: 'post',
  72. url: pagePath+"/build/floor/save",
  73. dataType:"json",
  74. success: function(data){
  75. if(data.status == "success"){
  76. succeedMessage(data.message);
  77. var index = parent.layer.getFrameIndex(window.name);
  78. parent.location.reload();
  79. parent.layer.close(index);
  80. }else {
  81. // $(form).find(":submit").attr("disabled", false);
  82. errorMessage(data.message);
  83. }
  84. },
  85. error: function () {
  86. errorMessage('系统错误!');
  87. }
  88. });
  89. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  90. },
  91. });