streetInfo.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. $(function () {
  2. $("#form-street-edit").validate({
  3. rules:{
  4. location:{
  5. maxlength:128
  6. },
  7. contact: {
  8. maxlength:64
  9. },
  10. phone: {
  11. isMobile:true
  12. },
  13. email: {
  14. isEmail:true,
  15. maxlength:64
  16. }
  17. },
  18. onkeyup:false,
  19. focusCleanup:true,
  20. success:"valid",
  21. submitHandler:function(form){
  22. $(form).ajaxSubmit({
  23. type: 'post',
  24. url: pagePath+"/street/streetInfo/update",
  25. dataType:"json",
  26. success: function(data){
  27. if (data.success) {
  28. succeedMessage(data.message);
  29. }else {
  30. // $(form).find(":submit").attr("disabled", false);
  31. errorMessage(data.message);
  32. }
  33. }
  34. });
  35. return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
  36. },
  37. errorPlacement: function(error, element) {
  38. if(element.attr('id') == 'rest_area'){
  39. error.addClass(' label_error')
  40. }
  41. error.appendTo(element.parent());
  42. }
  43. });
  44. });