0

I am a new to js and am trying to figure out if there is a way to either modify an existing button within AnyTime Datepicker or add a new one that will clear the date from the field.

I see this as a possible solution, but can't figure out where to insert it into the anytime.js to prevent the AnyTime datepicker from breaking:

}).keyup(function(e) {
    if(e.keyCode == 8 || e.keyCode == 46) {
        $.datepicker._clearDate(this);
    }
});

Okay, so I have below that works in Chrome / firefox, but not in IE 9. In IE 9 I click on Clear button and it brings up the date picker. If I click on it twice in IE it will clear the field. How can I get it to be compatible with IE9:

<tr>
                        <td>
                            <label class="width100 right displayInlineBlock padBottom5">Received:
                                <input class="width70 calendarBackground" type="text" maxlength="4000" name="received" id="received" value="<%=report.getFormattedReceived()%>" />
                                <script>
                                    AnyTime.picker( "received", { format: "%d %b %y", firstDOW: 1 } );
                                </script>
                                <input type="button" id="receivedClear" value="Clear" />
                                <script>
                                    $("#receivedClear").click( function(e) {
                                    $("#received").val("").change(); } );
                                </script>
                            </label>
                        </td>
                    </tr>

Thanks!

4

1 回答 1

1

问题是,当日期字段获得焦点时,选择器会出现,并且它会不断更新字段以显示当前选择的日期(默认为空时的当前日期)。因此,根据设计,调用change()以调出选择器也应该使用当前日期/时间填充该字段。

如果你想清空场地,你应该打电话val('')而不是调出选择器。如果要显示选择器,那么您不应该清除该字段,或者愿意接受选择器会将字段重置为当前时间。

我正在开发一个新的选择器,在选择器被解雇之前不会自动更新字段,但距离发布还有好几个月。

于 2014-05-21T15:28:48.733 回答