BootstrapValidator bootstrap-select verifies the unavailable solution. validator verifies the select

Source: Internet
Author: User

BootstrapValidator bootstrap-select verifies the unavailable solution. validator verifies the select

Three steps are required to resolve the unavailability of bootStrapValidator bootStrap-select verification:

Ideas:Assign the selected value from the multiple selection drop-down box to a hidden input component and verify the input component (bootstrap-validator hidden by default, disabled components are not verified, can be changed through the excluded attribute), the specific steps are as follows:

1. Form Verification initialization (js)

$ ('# MyModalForm '). bootstrapValidator ({message: 'This value is not valid', excluded: [': disabled'], // [': disabled', ': Den den', ': not (: visible) '] // sets the hidden component to verify that feedbackIcons: {valid: 'glyphicon glyphicon-OK', invalid: 'glyphicon glyphicon-delete', validating: 'glyphicon glyphicon-refresh'}, fields: {roleid: {message: 'Role invalid ', validators: {notEmpty: {message: 'Role cannot be blank '}}}}})

2. bootStrap-select component configuration (jsp page)

<Input type = "hidden" class = "form-control" id = "roleid" name = "roleid"> <select class = "selectpicker form-control" multiple data-width = "60%" id = "roleidForSelect" title = "--- select ---"> </select>

3. assign a value to the corresponding input after selecting multiple drop-down lists.

$ ('# Roleidforselect '). on ('ddden. bs. select ', function (e) {// This method is registered to the $ (function () {}) function var tmpSelected = $ (' # roleidforselect '). val (); if (tmpSelected! = Null) {$ ('# roleid '). val (tmpSelected);} else {$ ('# roleid '). val ("") ;}// because the input is hidden, some bugs may occur during verification. Here, you can manually verify the hidden input component $ ('# myModalForm '). data ('bootstrapvalidator '). updateStatus ('roleid', 'not _ validated '). validateField ('roleid ');});

If you want to study in depth, you can click here to learn and attach three special topics:

Bootstrap tutorial

Bootstrap tutorial

Bootstrap Table tutorial

Bootstrap plugin usage tutorial

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.