Question 1:
The following code:
<input type= "hidden" name= "ProductId"/>
$ ("#addForm"). Bootstrapvalidator ({
fields: {
productId: {
validators: {
notempty: {message
: ' Please select a commodity '}}}}
;
Such a configuration does not validate the table cell ProductID at the time of submission because the bootstrapvalidator default configuration is for "hidden fields (: hidden), disabled domain (:D isabled), which field (: Not ( Visible)) "is not validated.
Workaround:
$ ("#addForm"). Bootstrapvalidator ({
//excluded:[": Hidden", ":d isabled", ": Not (visible)"],// Bootstrapvalidator's default configuration
excluded:[":d isabled"],//critical configuration, which means that only disabling domains are not validated, and other form elements are validated by
fields: {
ProductId: {
validators: {
notempty: {
message: ' Please select a commodity '
}
}}}
;
Question 2:
We tend to have such a demand as the following figure:
After the selection of goods will be in the ProductName to display the name of the product to the user, and in ProductID this hidden domain put a product ID.
In general, such operations are done by the program,
$ ("Input[name= ' productId ']"). Val (Data.productid);
Bootstrapvalidator This plugin cannot capture such "program assignment events", so there is no validation effect here, so we need to make a little workaround:
$ ("#addForm"). Bootstrapvalidator ({
//excluded:[": Hidden", ":d isabled", ": Not (visible)"],// Bootstrapvalidator's default configuration
excluded:[":d isabled"],//critical configuration, which means that only disabling domains are not validated, and other form elements are validated
fields: {
productId : {
trigger: "Change",//Issue 2. Key Configuration
validators: {
notempty: {
message: ' Please select an item '
}}
}
});
The "Change" event
("Input[name= ' productId ']") is triggered once after the assignment. Val (data.productid). Change ();
After that, the bootrapvalidator will be caught with the "change" event triggering the effect of the validation.
The above is a small set to introduce the bootstrap validator for hidden domain validation and procedures for real-time validation of the problem analysis, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!