国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) A brief analysis of BootStrap Validator's problems with hidden domain verification and instant verification of program assignments

A brief analysis of BootStrap Validator's problems with hidden domain verification and instant verification of program assignments

Dec 03, 2016 am 10:25 AM

Question 1:

The following code:

<input type="hidden" name="productId"/>
$("#addForm").bootstrapValidator({
fields: {
productId: {
validators: {
notEmpty: {
message: &#39;請(qǐng)選擇一個(gè)商品&#39;
}
}
}
}
});

Such a configuration does not verify the form element productId when submitting. That is because the default configuration of bootstrapValidator is for "hidden domain (:hidden), disabled domain ( :disabled), that field (:not(visible))" are not verified.

Solution:

$("#addForm").bootstrapValidator({
//excluded:[":hidden",":disabled",":not(visible)"] ,//bootstrapValidator的默認(rèn)配置
excluded:[":disabled"],//關(guān)鍵配置,表示只對(duì)于禁用域不進(jìn)行驗(yàn)證,其他的表單元素都要驗(yàn)證
fields: {
productId: {
validators: {
notEmpty: {
message: &#39;請(qǐng)選擇一個(gè)商品&#39;
}
}
}
}
});

Problem 2:

We often have such needs, as shown below:

A brief analysis of BootStrap Validators problems with hidden domain verification and instant verification of program assignments

After selecting the product, the product name will be displayed to the user in productName, and in Put a product ID in the hidden field productId.

Normally such operations are done by programs,

$("input[name=&#39;productId&#39;]").val(data.productId);

bootstrapValidator plug-in cannot capture such "program assignment events", so the verification effect cannot be achieved here, so we need to make a small Variation:

$("#addForm").bootstrapValidator({
//excluded:[":hidden",":disabled",":not(visible)"] ,//bootstrapValidator的默認(rèn)配置
excluded:[":disabled"],//關(guān)鍵配置,表示只對(duì)于禁用域不進(jìn)行驗(yàn)證,其他的表單元素都要驗(yàn)證
fields: {
productId: {
trigger:"change", //問題2.關(guān)鍵配置
validators: {
notEmpty: {
message: &#39;請(qǐng)選擇一個(gè)商品&#39;
}
}
}
}
});
//賦值之后觸發(fā)一次“change”事件
$("input[name=&#39;productId&#39;]").val(data.productId).change();

In this way, the bootrapValidator will capture the "change" event because it is triggered, achieving the verification effect

The above is the BootStrap Validator introduced by the editor for hidden domain verification and program assignment A brief analysis of the problem of instant verification, I hope it will be helpful to everyone


Statement of this Website
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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)