0

I would like to set the value of the date picker field to be the current date by default. So every time I add a new row, i want that row to show the current date in the datepicker input field.

Thanks and let me know if you need any other information. I have the following code in my instructions field per this post:

<script>
   document.getElementsByClassName('hasDatepicker').value = (new Date()).format("m/dd/yy");
</script>

But that doesn't seem to be working.

/* EDIT */ I tried to adjust my code a bit to see if that worked, but it didn't. I am trying to avoid JQuery just in case ther is a loading issue.

<script>
    document.getElementsByClassName(''matrix-add").addEventListener('click', function() {
        document.getElementsByClassName('event_helper_date').value = (new Date()).format("m/dd/yy");
    });
</script>
2
  • you want cell value to be current date? or when showing datepicker want it to display current date (datepicker shows current date by default) (also see: setDate and defaultDate) api.jqueryui.com/datepicker/#method-setDate
    – GDmac
    Dec 4, 2013 at 9:28
  • yeah, I want the actual input value to be the current date when a new input loads. Then they can change it if they want. In this case 90% of the time it will just be the current date, but they want to save a step by having it default to that and then if they need to change it they can use the datepicker.
    – prosborne
    Dec 5, 2013 at 4:34

0

Your Answer

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

Browse other questions tagged or ask your own question.