Wednesday, June 10, 2015

JQuery - Disable keyboard input when using datepicker() function

<html>
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - No keyboard input</title>
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <script type="text/javascript">
    $(function () {
        $("#datepicker").datepicker({ maxDate: "-1D" }).attr('readonly', 'readonly');
        $("#datepicker").readonlyDatepicker(true);
    });
  </script>
</head>
<body>
  <p>
Date: <input type="text" id="datepicker"></p>
</body>
</html>

Reference : Restrict user to enter date manually in text field
http://stackoverflow.com/questions/30740545/restrict-user-to-enter-date-manually-in-text-field/30744481#30744481

No comments:

Post a Comment