0

While using date picker in my code its working when I have not called it inside the function like :

 <script src="~/Content/js/bootstrap-datepicker.js"></script>

    <script type="text/javascript">

            $('.datepicker').datepicker({
                autoclose: true,
                format: 'dd/mm/yyyy'
            });
    </script >

But when I am calling this inside function :

<script src="~/Content/js/bootstrap-datepicker.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $('.datepicker').datepicker({
            autoclose: true,
            format: 'dd/mm/yyyy'
        });
    });
</script >

its giving me error date picker is not defined. Please tell me where I am wrong. Thanks in advance.

3
  • 1
    Is your bootstrap-datepicker.js loading? That ~/ looks kind of scary :) Commented Mar 15, 2016 at 12:01
  • @VincentOrback its working without function it means path is correct and I have cross check this but no success :( Commented Mar 15, 2016 at 12:16
  • 1
    Kindly refer to this link stackoverflow.com/questions/17121021/… Commented Mar 15, 2016 at 12:33

1 Answer 1

0

Try changing the src link to a relative link (relative to the html page, that is).

E.g.: if the html page is in Content, the src should be:

js/bootstrap-datepicker.js
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.