Why Bootstrap Datepicker does not revalidate -


    **my html form is:**  <html>   <body>      <form role="form" class="margin_top" method="post" id="eventform">              <div class="form-group">                     <div class="input-group date form_date col-sm-12" data-date="" data-date-format="dd mm yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd" id="datepicker">                         <input class="form-control" size="16" type="text" value="" name="date_from" placeholder="date of arrival" readonly>                         <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>                     </div>                 </div>              <div class="form-group">                     <div class="input-group date form_date col-sm-12" data-date="" data-date-format="dd mm yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd" id="datepicker2">                         <input class="form-control" size="16" type="text" value="" name="date_to" placeholder="date of departure" readonly>                          <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>                     </div>                     <input type="hidden" id="dtp_input2" value="" />                 </div>       <button type="submit" name="send_request" class="btn btn-info bnt-md" value="send">send request</button>     </form>   </body>      <script>      $(document).ready(function() {         $('#datepicker')             .datepicker({                 format: 'mm/dd/yyyy'             })             .on('changedate', function(e) {                 // revalidate date field                 $('#eventform').formvalidation('revalidatefield', 'date_from');         });         $('#datepicker2')             .datepicker({                 format: 'mm/dd/yyyy'             })             .on('changedate', function(e) {                 // revalidate date field                 $('#eventform').formvalidation('revalidatefield', 'date_to');         });            $('#eventform').bootstrapvalidator({             feedbackicons: {                 valid: 'glyphicon glyphicon-ok',                 invalid: 'glyphicon glyphicon-remove',                 validating: 'glyphicon glyphicon-refresh'             },             fields: {                 date_from: {                         validators: {                             notempty: {                             message: 'the date required'                         },                         date: {                             format: 'mm/dd/yyyy',                             message: 'the date not valid'                         }                         }                     },                 date_to: {                         validators: {                             notempty: {                             message: 'the date required'                         },                         date: {                             format: 'mm/dd/yyyy',                             message: 'the date not valid'                         }                         }                     }             }         });     });     </script>      <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker.min.css" />     <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker3.min.css" />     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.4.5/css/bootstrapvalidator.min.css"  charset="utf-8">     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.4.5/js/bootstrapvalidator.min.js"></script>     <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.min.js"></script> </html> 

when not select date datepicker , submit form shows error message "the date require", again select date datepicker shows same error message. can't revalidate. how can solve problem?

hi please try script may help.

$(document).ready(function() {          $('#datepicker')              .datepicker({                  format: 'mm/dd/yyyy'              })              .on('changedate', function(e) {                  // revalidate date field                  $('#eventform').formvalidation('revalidatefield', 'date_from');          });          $('#datepicker2')              .datepicker({                  format: 'mm/dd/yyyy'              })              .on('changedate', function(e) {				  				if(new date( $('#date1').val()) >= new date($('#date2').val()))  				{  					alert('set date proper !');  					jquery('#date2').val('');  				}  				                  // revalidate date field                  //$('#eventform').formvalidation('revalidatefield', 'date_to');          });  		  		(function( $ ){  		 $.fn.formvalidation = function(t1,t2) {  		     // alert(t2);  	      return this;  		};   		})( jquery );              $('#eventform').bootstrapvalidator({              feedbackicons: {                  valid: 'glyphicon glyphicon-ok',                  invalid: 'glyphicon glyphicon-remove',                  validating: 'glyphicon glyphicon-refresh'              },              fields: {                  date1: {                          validators: {                              notempty: {                              message: 'the date required'                          },                          date: {                              format: 'mm/dd/yyyy',                              message: 'the date not valid'                          }                          }                      },                  date12: {                          validators: {                              notempty: {                              message: 'the date required'                          },                          date: {                              format: 'mm/dd/yyyy',                              message: 'the date not valid'                          }                          }                      }              }          });      });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/css/datepicker3.min.css" rel="stylesheet"/>  <link href="https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.4.5/css/bootstrapvalidator.min.css" rel="stylesheet"/>  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.bootstrapvalidator/0.4.5/js/bootstrapvalidator.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.3.0/js/bootstrap-datepicker.min.js"></script>        <form role="form" class="margin_top" method="post" id="eventform">                <div class="form-group">                      <div class="input-group date form_date col-sm-12" data-date="" data-date-format="dd mm yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd" id="datepicker">                          <input class="form-control" size="16" type="text" value="" name="date_from" id="date1" placeholder="date of arrival" readonly>                          <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>                      </div>                  </div>               <div class="form-group">                      <div class="input-group date form_date col-sm-12" data-date="" data-date-format="dd mm yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd" id="datepicker2">                          <input class="form-control" size="16" type="text" value="" name="date_to" placeholder="date of departure" id="date2" readonly>                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>                      </div>                      <input type="hidden" id="dtp_input2" value="" />                  </div>        <button type="submit" name="send_request" class="btn btn-info bnt-md" value="send">send request</button>      </form>

if problem info me. because not sure need you.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -