Anson Aştepta
Anson Aştepta

Reputation: 1143

Boostrap datepicker multiple date selector keep returning "Please enter a valid date."

I am using Bootstrap Multi Select Date Picker

HTML5:

 <div class="form-group ">
    <label for="unavailable_date" class="control-label col-lg-2" >unavailable date list</label>
             <div class="col-lg-10">
                 <input type="text" id="unavailable_date" class="form-control date" placeholder="unavailable date list">
          </div>
     </div>

JS

 $('.date').datepicker({
             multidate: true,
            format: 'dd-mm-yyyy'
        });

enter image description here

Whenever I click on submit button the validation message just appears and breaks the process, how may I disable the validation on this element?

Upvotes: 1

Views: 881

Answers (3)

Udal Pal
Udal Pal

Reputation: 232

$('.date').datepicker({
             multidate: true,
            format: 'dd-mm-yyyy'
        });
 
          
        $('#onSubmit').click(function(){
            var selectDate = $("#unavailable_date").val();
            console.log(selectDate);
        });
<html>

<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
</head>

<body>

<div class="form-group ">
    <label for="unavailable_date" class="control-label col-lg-2" >unavailable date list</label>
             <div class="col-lg-10">
                 <input type="text" id="unavailable_date" class="form-control date" placeholder="unavailable date list">
          </div>
     </div>
     
     <div class="form-group">
          <button id="onSubmit" class="btn btn-primary" >Submit</button>
     </div>

</body>

</html>

you can try this

Upvotes: 2

Anson Aştepta
Anson Aştepta

Reputation: 1143

Ok, the problem is another programmer has enabled jquery-validation, therefore, the submit button will always check and when the result is not matched the jquery-validation it will returns an error and break.

Upvotes: 0

Keerthi Puthanaveedu
Keerthi Puthanaveedu

Reputation: 26

I think the problem is in your css. I replicated the code you have posted and I didn't get "please enter a valid date error".

Upvotes: 1

Related Questions