stree_add.js 1.7 KB

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