| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- $(function () {
- $("#form-content-add").validate({
- rules:{
- name:{
- required:true,
- minlength:1,
- maxlength:45,
- remote: {
- url: pagePath+"/build/water/isExist",
- type: "get",
- data: {
- name: function () {
- return $("#name").val();
- }
- }
- }
- },
- remarks: {
- maxlength: 45,
- }
- },
- messages : {
- name : {
- remote: "该水表名已存在!"
- },
- remark: {
- maxlength: "备注长度不能超过45个字符!"
- }
- },
- onkeyup:false,
- focusCleanup:true,
- success:"valid",
- submitHandler:function(form){
- $(form).ajaxSubmit({
- type: 'post',
- url: pagePath+"/build/water/saveWater",
- dataType:"json",
- success: function(result){
- if (result.success) {
- smileMessage(result.message);
- setTimeClose();
- } else {
- errorMessage(result.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- }
- });
- });
|