| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- /*自定义jQuery校验是9位数字和字母*/
- jQuery.validator.addMethod("LetterAndNum9", function (value, element) {
- return this.optional(element) || /^[a-zA-Z0-9]{9}$/.test(value);
- }, "组织结构代码由9位数字或字母组成");
- $(function () {
- $("#form-content-edit").validate({
- rules: {
- company_name: {
- required: true,
- minlength: 1,
- maxlength: 45,
- remote: {
- url: pagePath + "/build/company/isExist",
- type: "get",
- data: {
- 'company_name': function () {
- return $("#company_name").val();
- },
- 'id': $("#companyId").val()
- }
- }
- },
- // is_product:{
- // required:true,
- //
- // },
- // is_industry:{
- // required:true
- // },
- // house_number:{
- // required:true,
- // minlength:1,
- // maxlength:45
- // },
- remark: {
- minlength: 1,
- maxlength: 255
- },
- contact: {
- required: true,
- minlength: 1,
- maxlength: 45
- },
- // floor:{
- // required:true,
- // digits:true,
- // min:1,
- // minlength:1,
- // maxlength:45
- // },
- location: {
- required: true,
- minlength: 1,
- maxlength: 80,
- },
- phone: {
- required: true,
- isMobile: true,
- },
- email: {
- required: true,
- email: true,
- },
- business: {
- // required:true,
- minlength: 1,
- maxlength: 255
- },
- },
- messages: {
- company_name: {
- remote: "该公司名已存在!"
- }
- },
- onkeyup: false,
- focusCleanup: true,
- success: "valid",
- submitHandler: function (form) {
- $(form).ajaxSubmit({
- type: 'put',
- url: pagePath + "/build/company/updateCompany/" + $("#companyId").val(),
- dataType: "json",
- success: function (data) {
- if (data.success) {
- succeedMessage(data.message);
- setTimeClose();
- } else {
- errorMessage(data.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- },
- errorPlacement: function (error, element) {
- if (element.attr('id') == 'business') {
- error.addClass(' label_error')
- }
- error.appendTo(element.parent());
- }
- });
- //企业编辑企业联系人信息
- $("#form-companyInfo-edit").validate({
- rules: {
- contact: {
- required: true,
- minlength: 1,
- maxlength: 45
- },
- phone: {
- required: true,
- isMobile: true,
- },
- staff_number: {
- // required: true,
- isGtZero: true
- },
- registration_capital: {
- min: 0,
- max: 999999999.9999,
- number: true,
- isFloat6Fn: $("#registration_capital").val()
- },
- organization_code: {
- //required: true,
- remote: {
- url: pagePath + "/company/companyInfoManage/getOrganization_code",
- type: "get",
- data: {
- organization_code: function () {
- return $("#organization_code").val();
- },
- id: $("#companyId").val()
- }
- },
- LetterAndNum9: $("#organization_code").val(),
- }
- },
- messages: {
- organization_code: {
- remote: "该组织机构代码已存在"
- }
- },
- onkeyup: false,
- focusCleanup: true,
- success: "valid",
- submitHandler: function (form) {
- setBuildStreetName();
- $(form).ajaxSubmit({
- type: 'put',
- url: pagePath + "/build/company/updateCompany/" + $("#companyId").val(),
- data: {
- timeStamp: new Date()
- },
- dataType: "json",
- success: function (data) {
- if (data.success) {
- succeedMessage(data.message);
- //location.reload();
- } else {
- errorMessage(data.message);
- }
- }
- });
- return false; // 非常重要,如果是false,则表明是不跳转,在本页上处理,也就是ajax,如果是非false,则传统的form跳转。
- }
- });
- });
|