mugifly / jquery-simple-datetimepicker

Date & time picker for jQuery, It's simple & clean.
http://mugifly.github.com/jquery-simple-datetimepicker
Other
260 stars 182 forks source link

Leave the input field empty by default #72

Closed boxoft closed 10 years ago

boxoft commented 10 years ago

This plugin seems to add a date (and time) to the input field all the time. I suggest adding an option to make it possible to leave the input field empty by default.

emiliodeg commented 10 years ago

yes I have the same idea!

boxoft commented 10 years ago

Here is what I do right now:

                    <script type="text/javascript">
                        $(function(){
                            $("#scheduled_from, #scheduled_to").mousedown(function() {
                                $(this).appendDtpicker();
                            });
                        });
                    </script>
to-ken commented 10 years ago

Yes, it will be very useful option!

In date filter on site http://www.planerka.info/tm you can leave finish date null.

LucasTheCure commented 10 years ago

To leave input field empty use option "autodateOnStart" for example:

$(function(){
    $('*[name=date]').appendDtpicker({
        "autodateOnStart": false
    });
});
richplane commented 10 years ago

[EDIT: Below comment retracted! I didn't have the most recent version...]

This doesn't seem to make any difference to me. If I have an empty value attribute for the input in my markup, I get JS errors from date.getFullYear().

Ideally, to validate the input, I want to display what the user entered in the input and flag it with a "please enter a date in dd/mm/yyyy format" label, and have dtpicker pop up on click to overwrite the contents.

I think that autodateOnStart should have the effect of making dtpicker neither set nor get contents of the value attribute in the markup (we have 'current' in the options object, after all). If people agree with that then I'll fork...

[I don't retract the below - it would have helped with the above...]

Would be good to have autodateOnStart added to the wiki at least so I can tell if I'm using that correctly. Would also be good to have more commenting in the code!