holiday_add.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. $(function () {
  2. $("#form-holiday-add").validate({
  3. rules: {
  4. configKey: {
  5. required: true,
  6. minlength: 1,
  7. maxlength: 9,
  8. remote: {
  9. url: pagePath + "/super/isExistHoliday",
  10. type: "get",
  11. data: {
  12. configKey: function () {
  13. return $("#configKey").val();
  14. },
  15. id: function () {
  16. return $("#id").val();
  17. }
  18. }
  19. }
  20. },
  21. configName: {
  22. minlength: 1,
  23. maxlength: 20
  24. }
  25. },
  26. messages: {
  27. configKey: {
  28. remote: "该年份假日信息已存在!"
  29. }
  30. },
  31. onkeyup: false,
  32. focusCleanup: true,
  33. focusInvalid:false,
  34. success: "valid",
  35. submitHandler: function (form) {
  36. $(form).ajaxSubmit({
  37. type: 'post',
  38. url: pagePath + "/super/holiday/save",
  39. dataType: "json",
  40. success: function (data) {
  41. if (data.status == "success") {
  42. succeedMessage(data.message);
  43. setTimeClose();
  44. } else {
  45. // $(form).find(":submit").attr("disabled", false);
  46. errorMessage(data.message);
  47. }
  48. },
  49. error: function () {
  50. errorMessage('系统错误!');
  51. }
  52. });
  53. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  54. }
  55. });
  56. });