Handcrafted with and a lot of by @nghuuphuoc
Hire me
← ejemplos
Use with the Bootstrap Button component.
<!-- Override the feedback icons position --> <style type="text/css"> #buttonGroupForm .btn-group .form-control-feedback { top: 0; right: -30px; } </style> <form id="buttonGroupForm" method="post" class="form-horizontal"> <div class="form-group"> <label class="col-xs-3 control-label">Gender</label> <div class="col-xs-9"> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default"> <input type="radio" name="gender" value="male" /> Male </label> <label class="btn btn-default"> <input type="radio" name="gender" value="female" /> Female </label> <label class="btn btn-default"> <input type="radio" name="gender" value="other" /> Other </label> </div> </div> </div> <div class="form-group"> <label class="col-xs-3 control-label">Languages</label> <div class="col-xs-9"> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default"> <input type="checkbox" name="languages[]" value="english" /> English </label> <label class="btn btn-default"> <input type="checkbox" name="languages[]" value="german" /> German </label> <label class="btn btn-default"> <input type="checkbox" name="languages[]" value="french" /> French </label> <label class="btn btn-default"> <input type="checkbox" name="languages[]" value="russian" /> Russian </label> <label class="btn btn-default"> <input type="checkbox" name="languages[]" value="italian"> Italian </label> </div> </div> </div> <div class="form-group"> <div class="col-xs-9 col-xs-offset-3"> <button type="submit" class="btn btn-default">Validate</button> </div> </div> </form> <script> $(document).ready(function() { $('#buttonGroupForm').formValidation({ framework: 'bootstrap', icon: { valid: 'glyphicon glyphicon-ok', invalid: 'glyphicon glyphicon-remove', validating: 'glyphicon glyphicon-refresh' }, // Since the Bootstrap Button hides the radio and checkbox // We exclude the disabled elements only excluded: ':disabled', fields: { gender: { validators: { notEmpty: { message: 'The gender is required' } } }, 'languages[]': { validators: { choice: { min: 1, max: 2, message: 'Please choose 1 - 2 languages you can speak' } } } } }); }); </script>