Powerful jQuery Bootstrap Form Validation with Example

Powerful jQuery Bootstrap Form Validation with Example

Powerful jQuery Bootstrap Form Validation with Example

Here is another example to validate your bootstrap form using jquery. This is very simple and user friendly plugins to validate your bootstrap form with additional features.

Using this plugin you can validate form easily.

This will shows you error icon and success icon too.

Here is a sample form to validate via jquery bootstrap validator.


  1. {!! Form::open(array('route' => 'your route','method'=>'POST','files'=>true,'id'=>'myform')) !!}
  2. <div class="col-xs-12 col-sm-12 col-md-12">
  3. <div class="form-group">
  4. <strong>Name:</strong>
  5. {!! Form::text('name', null, array('placeholder' => 'Name','class' => 'form-control')) !!}
  6. {!! $errors->first('name', '<p class="alert alert-danger">:message</p>') !!}
  7. </div>
  8. </div>
  9. <div class="col-xs-12 col-sm-12 col-md-12">
  10. <div class="form-group">
  11. <strong>Email:</strong>
  12. {!! Form::text('email', null, array('placeholder' => 'Email','class' => 'form-control')) !!}
  13. {!! $errors->first('email', '<p class="alert alert-danger">:message</p>') !!}
  14. </div>
  15. </div>
  16. <div class="col-xs-12 col-sm-12 col-md-12">
  17. <div class="form-group">
  18. <strong>Phone:</strong>
  19. {!! Form::text('phone', null, array('placeholder' => 'Mobile No','class' => 'form-control')) !!}
  20. {!! $errors->first('phone', '<p class="alert alert-danger">:message</p>') !!}
  21. </div>
  22. </div>
  23. <div class="col-xs-12 col-sm-12 col-md-12">
  24. <div class="form-group">
  25. <strong>Details:</strong>
  26. {!! Form::textarea('details', null, array('placeholder' => 'Details','class' => 'form-control','style'=>'height:100px')) !!}
  27. {!! $errors->first('details', '<p class="alert alert-danger">:message</p>') !!}
  28. </div>
  29. </div>
  30. <div class="col-xs-12 col-sm-12 col-md-12 text-center">
  31. <button type="submit" class="btn btn-primary">Submit</button>
  32. </div>
  33. {!! Form::close() !!}

Now lets add some scipt to validate this form.


  1. $(document).ready(function() {
  2. $('#myform').bootstrapValidator({
  3. message: 'This value is not valid',
  4. feedbackIcons: {
  5. valid: 'glyphicon glyphicon-ok',
  6. invalid: 'glyphicon glyphicon-remove',
  7. validating: 'glyphicon glyphicon-refresh'
  8. },
  9. fields: {
  10. name: {
  11. validators: {
  12. notEmpty: {
  13. message: 'Please enter your full name'
  14. }
  15. }
  16. },
  17. details: {
  18. validators: {
  19. notEmpty: {
  20. message: 'Please enter your details'
  21. }
  22. }
  23. },
  24. email: {
  25. validators: {
  26. notEmpty: {
  27. message: 'Please enter your email'
  28. }, emailAddress: {
  29. message: 'The value is not a valid email address'
  30. }
  31. }
  32. },
  33. phone: {
  34. validators: {
  35. notEmpty: {
  36. message: 'Please enter your phone no.'
  37. },
  38. digits: {
  39. message: 'The mobile phone number is not valid'
  40. },
  41. stringLength: {
  42. min: 10,
  43. max: 11,
  44. message: 'The phone no. must be 10 digits'
  45. }
  46. }
  47. },
  48. }
  49. });
  50. });

Don't forget to add library to validate form.

<script src="http://demo.expertphp.in/js/validator.js"></script>

Phone: (+91) 8800417876
Noida, 201301