0

I am having trouble making my date picker work using the input type="text". Any help would be great.

$(document).ready(function() {
  $("#checkin").datepicker();
  $("#checkout").datepicker();
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<label for="checkin">Checkin</label>
<input type="text" name="checkin" id="checkin" placeholder=" Check in"/>

<label for="checkout">Checkout</label>
<input type="text" name="checkout" id="checkout" placeholder=" Check out"/>

2
  • What is the error/problem? Seems to work fine for me. Commented Oct 15, 2017 at 11:57
  • @PhaniKumarM the date picker isnt showing up when I click on field. Instead you are just able to type anything Commented Oct 15, 2017 at 12:00

1 Answer 1

1

You can find the working sample below using your code. I have included jQuery, jQuery UI JS and CSS files.

$(function () {
  $("#checkin").datepicker();
  $("#checkout").datepicker();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<label for="checkin">Checkin</label>
<input type="text" name="checkin" id="checkin" placeholder=" Check in" />

<label for="checkout">Checkout</label>
<input type="text" name="checkout" id="checkout" placeholder=" Check out" />

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much, this worked a charm. Was just using the wrong jQuery library.
@CiaraSmith please accept the answer if it solved your problem. :)

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.