construir la opción altField opción altField
Sintaxis:
$(".selector").datepicker( { altField: "#field" } );
Enfoque: Primero, agregue los scripts jQuery UI necesarios para su proyecto.
<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel=”stylesheet”>
<script src = “https://code. jquery.com/jquery-1.10.2.js”></script>
<script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
Ejemplo:
HTML
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <link href= "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet"> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"> </script> <!-- JavaScript code --> <script> $(function () { $("#gfg").datepicker( { altField: "#field" } ); }); </script> </head> <body> <h1>GeeksforGeeks</h1> <h3>jQuery UI | datepicker altField option</h3> <!-- HTML --> <p>Enter Date: <input type="text" id="gfg"></p> <input type="text" id="field"> </body> </html>
Producción:
Referencia: https://api.jqueryui.com/category/widgets/