Update date input with value today

Thread is closed for posting
3 posts, 1 answers
  1. Ignacio
    Ignacio avatar
    21 posts
    Member since:
    Feb 2013

    Posted 16 Feb 2017 Link to this post

    I need to update date input with value today after change other input in the form.
    I don't know where is the problem. Don't works.


    My code:

    ---html -------------------------------------------------

                    <li class="form-content-item">
                        <label id="fechaField" class="field km-listview-label field--datetime-local">
                            <span class="field__label" data-bind="text: strings.servicio.servicioModel.editableListForm.fecha.title" style="width: 40%;"></span>
                            <input id="fecha" data-bind="value: addFormData.fecha, enabled: false" type="datetime-local" style="width: 60%; font-weight: bold;">
                    <li class="form-content-item">
                        <label id="importeField" class="field km-listview-label field--number">
                            <span class="field__label" data-bind="text: strings.servicio.servicioModel.editableListForm.importe.title" style="width: 40%;"></span>
                            <input id="importe" data-bind="value: addFormData.importe, events: { change: servicioModel.pagar }" type="number" style="width: 60%; font-     weight: bold; font-size: 1.5em; padding-top: 0.5em; visibility: initial; ">

                pagar: function() {
                    var i = $('#importe').val();
                    var p = $('#peaje').val();
                    var g = parseFloat(Number(i) + Number(p));
                    g = kendo.toString(parseFloat( g  ), '#.##')
                    var currDay = dFec();
                    currDay = kendo.toString(kendo.parseDate(currDay), 'dd/MM/yyyy HH:mm:ss');

        function dFec() {
        var d = new Date,
            dformat = [d.getDate(),
                    d.getFullYear()].join('/')+' '+
            return d;           

  2. Answer
    Anton Dobrev
    Anton Dobrev avatar
    609 posts

    Posted 21 Feb 2017 Link to this post


    It appears that the input with Id fecha is not in the markup, perhaps, it this is the case, otherwise it should be working as in this example (just select from the Some text field).

    Also, it may be better to use the MVVM properties instead of searching the element with jQuery as in this example (see the MVVM date).

    I hope this helps.

    Anton Dobrev
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Ignacio
    Ignacio avatar
    21 posts
    Member since:
    Feb 2013

    Posted 22 Feb 2017 in reply to Anton Dobrev Link to this post


    Thank you !

Back to Top