Bootstrap Select2 checksum does not affect the original format

Source: Internet
Author: User

<style>. Has-error. Select2-choice,. Has-error. Select2-choices,. has-error.simple. Select2-choice,. Has-error.simple. SE Lect2-choices{Border-color:#F40E33;    }</style><Divclass= "col-sm-12 col-md-6 col-lg-5">    <Divclass= "Form-group">        <label for= "Jq-validation-email"class= "Col-sm-4 Control-label">Carrier:</label>        <Divclass= "Col-sm-8">            <Selectclass= "Form-control x-select2"ID= "Carrier"name= "Carrier">                <option></option>#foreach ($item in $!{ Result.suppliers})<optionvalue="$! {Item.supplierid} "Data-taxno="$! {item.taxno} ">$! {Item.supplier}</option>#end</Select>        </Div>    </Div></Div><Divclass= "col-sm-12 col-md-6 col-lg-5">    <Divclass= "Form-group">        <label for= "Jq-validation-email"class= "Col-sm-4 Control-label">Invoice number<FontColor=red>&nbsp;*&nbsp;</Font>:</label>        <Divclass= "Col-sm-8">            <inputclass= "Form-control check notnull"ID= "Invoiceno"name= "Invoiceno"type= "text">        </Div>    </Div></Div>

Verifying jquery:

//select2 Checksum: change$ (document). On ("Change", ". Select2-offscreen",function () {            varValue = $ ( This). Val (); varID = $ ( This). attr ("id"); if(Value = =NULL|| Value = = "") {                $( This). addclass ("Myerrorclass"); $("#s2id_" +id). Parent (). addclass ("Has-error"); } Else {                $( This). Removeclass ("Myerrorclass"); $("#s2id_" +id). Parent (). Removeclass ("Has-error");                }        }); //Check SELECT2 When submitting a button click        functionCheckselect2isnull () {varResultflag =false; varnum = 0; $("Select.select2-offscreen"). each (function(){                if($( This). Hasclass ("Myerrorclass")){                    varID = $ ( This). attr ("id"); $("#s2id_" +id). Parent (). addclass ("Has-error"); //$ ("#s2id_" +id). CSS ("Border-color", "Red"). CSS ("Border", "1");num++;            }            }); if(num = = 0) {Resultflag=true; } Else{Resultflag=false; }            returnResultflag; }

At this point call the Checkselect2isnull () method, you can verify the Select2 box is empty!!! Not back to affect the original layout!!!

Bootstrap Select2 checksum does not affect the original format

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.