1

The datepicker works on my bootstrap folder. However, when I move everything into laravel, it does not work. I don't really understand that how css and js work in laravel, so that is why I am here :).

/resources/sass/app.scss

//css
@import url('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');

//js
@import url('https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js');
@import url('https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js');
@import url('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js');

              <!--DatePicker-->
              <div class="col-md-4">
                <h4 class="">Prefer Date</h3>
                <form>
                    <div class="">
                        <!-- <label for="date" class="col-sm-1 col-form-label">Date</label> -->
                        <div class="">
                            <div class="input-group date" id="datepicker">
                                <input type="text" class="form-control">
                                <span class="input-group-append">
                                    <span class="input-group-text bg-white">
                                        <i class="fa fa-calendar"></i>
                                    </span>
                                </span>
                            </div>
                        </div>
                    </div>
                </form>
              </div>
              <script type="text/javascript">
                $(function() {
                    $('#datepicker').datepicker();
              });
              </script>
3
  • Have you checked the console? what errors did u get? Commented Nov 30, 2021 at 10:56
  • I have, everything is fine, but the datepicker does not pop up Commented Nov 30, 2021 at 11:00
  • Shouldn't u use the datepicker on the field itself? So: <input type="text" class="form-control" id="datepicker"> Commented Nov 30, 2021 at 11:10

1 Answer 1

1

I just copied your code and it worked if you swap this:

<input type="date" class="form-control">

So change the input type from text to date, since it is a Datepicker you are trying to build.

I recently had a similar issue and that is my code for my date picker:

<div class="flex flex-wrap -mx-3 mb-6">
    <div class="w-full px-3">
         <label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2 text-base" for="enddate"> Enddatum </label>
         <input class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight id="enddate" name="enddate" type="date" placeholder="Enddatum">
    </div>
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.