3

Using the jquery datepicker ui, the value attributes of the associated html fields don't update immediately.

Example: http://jsfiddle.net/4tXP4/

From the horses mouth: http://jqueryui.com/demos/datepicker/alt-field.html

If you inspect the elements you will see that neither value attributes update.

What' missing with these?

0

2 Answers 2

4

if you don't want another input field then use onSelect but the .val function does not update the value attribute, so you need to be a bit more raw

$("#datepicker_start").datepicker({
    onSelect: function(dateText, datePicker) {
       $(this).attr('value', dateText);
    }
});
Sign up to request clarification or add additional context in comments.

Comments

2

working demo http://jsfiddle.net/UBMXq/ or http://jsfiddle.net/3BLwK/9/ or http://jsfiddle.net/wrCv7/

1 things:

  • missing # "altField":"#startDate"
  • (optional) i.e. DateFormat might need some attention - I reckon dont use value in your hidden input

Hope this helps! :)

code

$(document).ready(function() {
    $("#startDate_picker").datepicker({
        "altField":"#startDate",
        "dateFormat":"d M y",
        "altFormat":"Y-m-d",
        "changeMonth":true,
        "changeYear":true
    });
});

1 Comment

@Ashley Indeed, Glad it helped :) also you might wanna take a look in the date format but you know better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.