dictionary_item_edit.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. $(function () {
  2. $("#form-dictionaryitem-edit").validate({
  3. rules: {
  4. name: {
  5. required: true,
  6. minlength: 1,
  7. maxlength: 60,
  8. remote: {
  9. url: pagePath + "/super/isExistDictionaryItem",
  10. type: "get",
  11. data: {
  12. name: function () {
  13. return $("#name").val();
  14. },
  15. value: '',
  16. id: function () {
  17. return $("#id").val();
  18. },
  19. typeId: function () {
  20. return $("#typeId").val();
  21. }
  22. }
  23. }
  24. },
  25. value: {
  26. required: true,
  27. minlength: 1,
  28. maxlength: 60,
  29. remote: {
  30. url: pagePath + "/super/isExistDictionaryItem",
  31. type: "get",
  32. data: {
  33. name: '',
  34. value: function () {
  35. return $("#value").val();
  36. },
  37. id: function () {
  38. return $("#id").val();
  39. },
  40. typeId: function () {
  41. return $("#typeId").val();
  42. }
  43. }
  44. }
  45. }
  46. },
  47. messages: {
  48. name: {
  49. remote: "该数据类型条目已存在!"
  50. },
  51. value: {
  52. remote: "该数据类型值已存在!"
  53. }
  54. },
  55. onkeyup: false,
  56. focusCleanup: true,
  57. focusInvalid:false,
  58. success: "valid",
  59. submitHandler: function (form) {
  60. // $(form).find(":submit").attr("disabled", true);
  61. $(form).ajaxSubmit({
  62. type: 'post',
  63. url: pagePath + "/super/dictionaryItem/save",
  64. dataType: "json",
  65. success: function (data) {
  66. if (data.success) {
  67. succeedMessage(data.message);
  68. setTimeClose();
  69. } else {
  70. // $(form).find(":submit").attr("disabled", false);
  71. errorMessage(data.message);
  72. }
  73. },
  74. error: function () {
  75. errorMessage('系统错误!');
  76. }
  77. });
  78. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  79. }
  80. });
  81. });