Boostrap Ajax Form Validation submission

Source: Internet
Author: User
Tags toastr

===============================================================================

1.

1 <link href="<%=basePath %>bootstrap/css/bootstrap-datetimepicker.min.css"rel="external nofollow" rel="stylesheet"media="screen">

===============================================================================

$( function (){ /* 文档加载,执行一个函数*/ // $(".submit_review").attr({"disabled":"disabled"});   $( ‘#defaultForm‘ ).bootstrapValidator({      message: ‘This value is not valid‘ ,      feedbackIcons: { /*输入框不同状态,显示图片的样式*/       valid: ‘glyphicon glyphicon-ok‘ ,       invalid: ‘glyphicon glyphicon-remove‘ ,       validating: ‘glyphicon glyphicon-refresh‘      },      fields: { /*验证*/       company_name: { /*键名username和input name值对应*/        validators: {         notEmpty: { /*非空提示*/          message: ‘公司名称不能为空‘         }, //       stringLength: {/*长度提示*/ //        min: 6, //        max: 30, //        message: ‘用户名在6到30之间‘ //       }/*最后一个没有逗号*/        }       },       company_id: {        validators: {         notEmpty: {          message: ‘公司ID不能为空‘         },        }       },       equipment_ip: {        validators: {         notEmpty: {          message: ‘设备IP不能为空‘         },         regexp: {          regexp: /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/,          message: ‘设备IP不合法‘           }        }       },      }    })   });

===============================================================================

23456789101112131415161718192021222324252627282930313233343536373839 $("#btn_reset").click(function(event) {   /* Act on the event */  $(‘#defaultForm‘).data(‘bootstrapValidator‘).resetForm(true);  });  $("body").on(‘click‘, ‘#btn_submit_add‘, function(event) {   /* Act on the event */  $(‘#defaultForm‘).bootstrapValidator(‘validate‘);   var flag = $("#defaultForm").data(‘bootstrapValidator‘).isValid();   if (!flag) {    toastr.error("填写有误,请重新填写!");   } else {    $.post(‘addEquipmentInfoCheck.action‘, {     "equipmentInfoCheck.companyId": $("#company_id").val(),     "equipmentInfoCheck.companyName": $("#company_name").val(),     "equipmentInfoCheck.machineRoom": $("#computer_room").val(),     "equipmentInfoCheck.equipmentCabinet": $("#cabinet").val(),     "equipmentInfoCheck.deviceType": $("#equipment_type").val(),     "equipmentInfoCheck.deviceName": $("#equipment_name").val(),     "equipmentInfoCheck.deviceIp": $("#equipment_ip").val(),     "equipmentInfoCheck.deviceBrand": $("#equipment_brand").val(),     "equipmentInfoCheck.deviceModel": $("#equipment_model").val(),     "equipmentInfoCheck.position": $("#shelf_position").val(),     "equipmentInfoCheck.deviceSn": $("#equipment_sn").val(),     "equipmentInfoCheck.devicePn": $("#equipment_pn").val(),     "equipmentInfoCheck.state":1    }, function(data, textStatus, xhr) {     /*optional stuff to do after success */    if (textStatus == "success") {      // e.preventDefault();      $(‘#defaultForm‘).data(‘bootstrapValidator‘).resetForm(true);      $("#myModal_add").modal(‘hide‘);      toastr.success("提交成功");     }else{      $("#myModal_add").modal(‘hide‘);      toastr.error("提交失败");     }    });   }  });

Boostrap Ajax Form Validation submission

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.