0

I'm trying to create an input to set a date to select, but in the console I always get this error:

Uncaught TypeError: $(...).datepicker is not a function

This is the code I have for scripts and css:

$(document).ready(function() {
  $("#fechaInicio").datepicker();
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="styles/displaytag.css" type="text/css">
<link rel="stylesheet" href="styles/common.css" type="text/css">

<!-- Bootstrap -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>

<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<!-- FontAwesome (iconos) -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">

<!-- Quilljs -->
<link href="https://cdn.quilljs.com/1.0.0/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>

<div class="form-group col-md-4">
  <div>
    <label for="fechaInicio"><spring:message code="fechaInicio" /></label>
    <input type="text" id="fechaInicio" />
  </div>
</div>

I'm using the tags of Spring for the form, but I also get the same result with basic inputs

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
DaniR
  • 85
  • 12
  • https://stackoverflow.com/questions/1212696/jquery-ui-datepicker-datepicker-is-not-a-function check it out – Sushil Dec 20 '18 at 15:18
  • have you tried importing jquery-ui from the jsp form? Also it might be a conflict caused by jquery and jquery-ui. Try removing jquery and see if that fixed your issue – sbattou Dec 20 '18 at 15:22
  • 2
    I placed your code in to a snippet where it appears to work fine. Note that I amended the Spring controls to the actual output HTML. You need to check the console for errors and also ensure that the output HTML matches what you are expecting it to be – Rory McCrossan Dec 20 '18 at 15:23
  • @RoryMcCrossan I see you everywhere, you been killing the game G – sbattou Dec 20 '18 at 15:25

0 Answers0