dictionary_item_add.js 2.6 KB

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