Comprehensive parsing of Bootstrap forms using methods (Form control state) _javascript tips

Source: Internet
Author: User
Tags button type

One, Focus state
The focus state is implemented through the pseudo class: focused. The focus state of the form control in the bootstrap frame removes the outline default style and adds the shadow effect again.

<form role= "form" class= "Form-horizontal" >
 <div class= "Form-group" > <div class= "col-xs-6"
 >
 <input class= "Form-control input-lg" type= "text" placeholder= "not focus effect" >
 </div>
 < Div class= "col-xs-6" >
 <input class= "Form-control input-lg" type= "text" placeholder= "focus point State effect" >
 </div>
 </div>
</form>

Second, disabled status
The disabled state of the form control for the bootstrap framework is the same as the normal form disabled state implementation method, adding the property "disabled" on the corresponding form control.

<form role= "Form" > <input class= "Form-control input-lg" id= "Disabledinput" type= "
 text" placeholder= " The form has been disabled and cannot be entered "disabled>
 <fieldset disabled> <div class=" Form-group "
 >
 <label for=" Disabledtextinput > Disabled input box </label>
 <input type= "text" id= "Disabledtextinput" class= "Form-control" placeholder= "no input" >
 </div>
 <div class= "Form-group" >
 <label for= "Disabledselect" > Disable drop-down box </label>
 <select id= "Disabledselect" class= "Form-control" >
 <option> not selectable < /option>
 </select>
 </div>
 <div class= "checkbox" >
 <label>
 <input type= "checkbox" > cannot select
 </label>
 </div>
 <button type= "Submit" class= "BTN" Btn-primary "> Submit </button>
 </fieldset>
</form>

Third, verify the status
When making a form, it is unavoidable to make form validation. You also need to provide validation status styles, which are also available in the bootstrap framework.
1. Has-warning: Warning Status (yellow)
2. Has-error: Error status (red)
3. Has-success: Success status (Green)
You only need to add the State class name on the Form-group container when you use it

<form role= "Form" >
 <div class= "Form-group has-success" > <label class= "Control-label" for= "
 InputSuccess1 "> Success status </label>
 <input type=" text "class=" Form-control "id=" inputSuccess1 "placeholder = "Success Status" >
 </div>
 <div class= "Form-group has-warning" >
 <label class= "Control-label" For= "InputWarning1" > Warning status </label>
 <input type= "text" class= "Form-control" id= "InputWarning1" placeholder= "Warning Status" >
 </div>
 <div class= "Form-group has-error" >
 <label class= " Control-label "for=" InputError1 "> Error status </label>
 <input type=" text "class=" Form-control "id=" InputError1 "placeholder=" error status >
 </div>
</form>

If you want to further study, you can click here to learn, and then attach two wonderful topics: Bootstrap Learning Tutorials Bootstrap Practical course

The above is a detailed description of the state of the bootstrap form control, and more content will be updated continuously, I hope you continue to pay attention.

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.