search
Homephp教程PHP开发How to write bootstrapValidator custom validation method

The example in this article shares how to write the bootstrapValidator custom verification method for your reference. The specific content is as follows

//表单验证
issueInvoiceForm.validation = function(){
 $('#issueInvoiceForm').on('init.field.bv', function(e, data) {
    var $icon   = data.element.data('bv.icon'),
      options  = data.bv.getOptions(),           // Entire options
      validators = data.bv.getOptions(data.field).validators; // The field validators
    if (validators.notEmpty && options.feedbackIcons && options.feedbackIcons.required) {
     $icon.addClass(options.feedbackIcons.required).show();
    }
  }).bootstrapValidator({
    container:'popover',
 feedbackIcons: {
  required: 'glyphicon glyphicon-asterisk requiredStar',
      valid: 'glyphicon glyphicon-ok',
      invalid: 'glyphicon glyphicon-remove',
      validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
     invoiceDate:{validators: {notEmpty: {message: '开票日期不能为空'}}},//开票日期
     code:{validators: {notEmpty: {message: '发票编码不能为空'}}},
     amount:{
     validators:{
      notEmpty: {message: '发票金额不能为空'},
      numeric: {message: '发票金额只能输入数字'},
      callback: {
             message: '开票金额小于选中金额',
             callback: function(value, validator) {
              return false;
             }
           }
 
     }
     },
     taxRate:{
     validators:{
      notEmpty: {message: '税率不能为空'},
      numeric: {message: '税率只能输入数字'}
     }
     },
     taxAmount:{
     validators:{
      notEmpty: {message: '税额不能为空'},
      numeric: {message: '税额只能输入数字'}
     }
     },
    },group:'.validateDiv'
 }).on('success.form.bv', issueInvoiceForm.issueInvoiceFormBtn).on('error.form.bv',function(){
  $("#issueInvoiceFormBtn").removeAttr("disabled");//将保存按钮去除disabled
   $(".has-error:visible:first").find(":input").focus();
  });
};


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools