1

JavaScript function after clicking on clear button

function resetTime() {
    document.getElementById("to_time").valueAsDate = null;
}

PrimeFaces calendar tag

<p:calendar id="to_time"
            value="#{anomaliesList.toDate}"
            readonlyInput="true"
            maxdate="#{currentDate}"
            size="16"
            pattern="dd/MM/yyyy HH:mm" />
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
lada
  • 263
  • 2
  • 8

1 Answers1

1

First of all, p:calendar is deprecated. Use p:datePicker instead.

The easiest way to deal with this is setting a widgetVar on your p:datePicker. This allows you to use the client side API.

To reset a date, use:

PF('yourWidgetName').setDate(null);

Note that if you want to use getElementById you probably need to incorporate the form clientId.

See also:

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102