jQWidgets Forums

jQuery UI Widgets Forums Editors DateTimeInput How to put the formatted date string in another text box

This topic contains 3 replies, has 2 voices, and was last updated by  sjkcwatson 10 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • sjkcwatson
    Participant

    I have the following script that fires when the datetimeinput changes
    <script type=”text/javascript”>
    $(document).ready(function () {
    // Create a jqxDateTimeInput
    $(“#jqxDateTimeInput_TourCompletedDate”).jqxDateTimeInput({ width: ‘100px’, height: ’25px’, formatString: ‘mm/dd/yyyy’ });
    $(‘#jqxDateTimeInput_TourCompletedDate’).on(‘valuechanged’, function (event) {
    var jsDate = event.args.date;
    document.getElementById(“myTourCompletedDate”).value =jsDate;
    });
    });
    </script>

    the jadate that is written to my input box “myTourCompletedDate” looks like this Wed Jul 16 00:00:00 CDT 2014 when I want it to look like this 07/16/14. I understand that the formatstring is for the datetimeinput control view only, but I would appreciate any suggestions on how to make the .value field I write send the text in the same date format. Thanks!


    sjkcwatson
    Participant

    Specifically, when I try to take the datestring in that format (‘Wed Jul 16 00:00:00 CDT 2014’) and insert into via a sql stored procedure I get

    Conversion failed when converting date and/or time from character string.

    I just need it in a datetime format in the mytourcompleteddate text box so that sql will recognize it as a valid date format.

    Any suggestions greatly appreciated! Been searching all afternoon with no luck so far.


    Peter Stoev
    Keymaster

    Hi sjkcwatson,

    jqxDateTimeInput is a JavaScript widget and as such it works with JavaScript Date objects. To learn how to use the JavaScript Date objects and how to format them, please look at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    sjkcwatson
    Participant

    Thanks. After several days of trial and error, I finally found a solution that works digging through the forums here. Thought I’d post it in case someone else is looking.

    $(‘#jqxDateTimeInput_TourCompletedDate’).on(‘valuechanged’, function (event) {
    //var jsDate = event.args.date;
    var dateString = $(“#jqxDateTimeInput_TourCompletedDate”).find(‘input’).val();
    document.getElementById(“myTourCompletedDate”).value = dateString;
    });

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.