Receive date from datapicker

Asked

Viewed 79 times

1

I am creating a site where I have a datapicker using the following website I wanted when I was going to save to fetch the date that was chosen from the datapicker that appears instead of the date of the textbox.

  • Good morning, when loading your page the Datepicker already load setando the text that it will manipulate, then you will have to take the data of this text... your doubt is the same?

  • I don’t know what you mean

  • You’ve already implemented Datepicker in your project?

  • 1

    already implemented the above site

  • and you are storing in a correct Textbox?

  • yes. But I don’t want to convert what is in the textbox because it will be a string and then changes the date according to the country. wanted to take the date of the calendar itself and not the textbox

  • Gives somehow to fetch the value of the calendar that appears when you click on the textbox?

  • 1
Show 3 more comments

1 answer

0

Good afternoon, below is a code that may be what you are looking for. The code besides showing the formatted date in the "datepicker" field in "Alternate" it shows without formatting, leaves original. link to documentation: https://jqueryui.com/datepicker/#alt-field

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>jQuery UI Datepicker - Populate alternate field</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#datepicker" ).datepicker({
      altField: "#alternate",
      altFormat: "DD, d MM, yy"
    });
  } );
  </script>
</head>
<body>
 
<p>Date: <input type="text" id="datepicker">&nbsp;<input type="text" id="alternate" size="30"></p>
 
 
</body>
</html>

  • 1

    not i intend to have at the same the dd/mm/yyyy but instead of being passed by string be passed by . date, . getdate or something like that pass the date

  • You have already looked in the documentation if the function passes "Date", I believe it already passes as string and so you will have to convert when sending your data...

  • 1

    and convert by Tryparse?

  • Yes, because it will convert to the application site... English, French, Brazil.... no and that’s what you want?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.