简体   繁体   中英

Bootstrap 3 Form Validation Using built-in Styles

I would like to implement form validation using Bootstrap3's CSS (For Example: On Submit, assuming all forms are filled in correctly, display an "alert alert-success". If failed, display "alert alert-danger" containing an explanation to the failure (Ex: Please enter a valid name). Right now, all I can get to work is requiring text in a field (using HTML5 required tag) without the ability to display any alerts.

Current Code: http://pastebin.com/AjfUA26n

Website: http://infenterprises.com/contact/

You will need to do two things:

  1. Do server side validation. Client side validation can be a nice help for your user, but it doesn't replace server side validation for security reasons. That being said
  2. you will need to use Javascript to do client side validation and display the result. A nice helper when using bootstrap is http://bootstrapvalidator.com/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM