Powerful jQuery Bootstrap Form Validation with Example

Powerful jQuery Bootstrap Form Validation with Example

In this post we will give you information about Powerful jQuery Bootstrap Form Validation with Example. Hear we will give you detail about Powerful jQuery Bootstrap Form Validation with ExampleAnd how to use it also give you demo for it if it is necessary.

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. <divclass="col-xs-12 col-sm-12 col-md-12">
  3. <divclass="form-group">
  4. <strong>Name:</strong>
  5. {!! Form::text('name', null, array('placeholder' => 'Name','class' => 'form-control')) !!}
  6. {!! $errors->first('name', '<pclass="alert alert-danger">:message</p>') !!}
  7. </div>
  8. </div>
  9. <divclass="col-xs-12 col-sm-12 col-md-12">
  10. <divclass="form-group">
  11. <strong>Email:</strong>
  12. {!! Form::text('email', null, array('placeholder' => 'Email','class' => 'form-control')) !!}
  13. {!! $errors->first('email', '<pclass="alert alert-danger">:message</p>') !!}
  14. </div>
  15. </div>
  16. <divclass="col-xs-12 col-sm-12 col-md-12">
  17. <divclass="form-group">
  18. <strong>Phone:</strong>
  19. {!! Form::text('phone', null, array('placeholder' => 'Mobile No','class' => 'form-control')) !!}
  20. {!! $errors->first('phone', '<pclass="alert alert-danger">:message</p>') !!}
  21. </div>
  22. </div>
  23. <divclass="col-xs-12 col-sm-12 col-md-12">
  24. <divclass="form-group">
  25. <strong>Details:</strong>
  26. {!! Form::textarea('details', null, array('placeholder' => 'Details','class' => 'form-control','style'=>'height:100px')) !!}
  27. {!! $errors->first('details', '<pclass="alert alert-danger">:message</p>') !!}
  28. </div>
  29. </div>
  30. <divclass="col-xs-12 col-sm-12 col-md-12 text-center">
  31. <buttontype="submit"class="btn btn-primary">Submit</button>
  32. </div>
  33. {!! Form::close() !!}
 {!! Form::open(array('route' => 'your route','method'=>'POST','files'=>true,'id'=>'myform')) !!}             <div >            <div >                <strong>Name:</strong>                {!! Form::text('name', null, array('placeholder' => 'Name','class' => 'form-control')) !!}                 {!! $errors->first('name', '<p >:message</p>') !!}            </div>        </div>         <div >            <div >                <strong>Email:</strong>                {!! Form::text('email', null, array('placeholder' => 'Email','class' => 'form-control')) !!}                 {!! $errors->first('email', '<p >:message</p>') !!}            </div>        </div>       <div >            <div >                <strong>Phone:</strong>                {!! Form::text('phone', null, array('placeholder' => 'Mobile No','class' => 'form-control')) !!}                 {!! $errors->first('phone', '<p >:message</p>') !!}            </div>        </div>        <div >            <div >                <strong>Details:</strong>                {!! Form::textarea('details', null, array('placeholder' => 'Details','class' => 'form-control','style'=>'height:100px')) !!}                 {!! $errors->first('details', '<p >:message</p>') !!}            </div>        </div>        <div >                <button type="submit" >Submit</button>        </div>      {!! 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. });
$(document).ready(function() {      $('#myform').bootstrapValidator({        message: 'This value is not valid',        feedbackIcons: {            valid: 'glyphicon glyphicon-ok',            invalid: 'glyphicon glyphicon-remove',            validating: 'glyphicon glyphicon-refresh'        },        fields: {            name: {                validators: {                    notEmpty: {                        message: 'Please enter your full name'                    }                }            },            details: {                validators: {                    notEmpty: {                        message: 'Please enter your details'                    }                }            },                                  email: {                validators: {                    notEmpty: {                        message: 'Please enter your email'                    }, emailAddress: {                        message: 'The value is not a valid email address'                    }                }            },               phone: {                        validators: {                          notEmpty: {                        message: 'Please enter your phone no.'                    },                digits: {                        message: 'The mobile phone number is not valid'                    },                    stringLength: {                        min: 10,                         max: 11,                         message: 'The phone no. must be 10 digits'                    }                }            },                           }            });  });

Don’t forget to add library to validate form.

<script src="//js/validator.js"></script>

Show Demo

Hope this code and post will helped you for implement Powerful jQuery Bootstrap Form Validation with Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

8  +  1  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US