I am trying to add a validation to the datepicker so that users won't be able to select past dates. The datepicker is built via ui-component and the code snippet is as follows:

enter image description here

I have checked this link where in they have said to add the javascript in the template file but in our case we don't have any template file. My case is similar to this post but not getting where to put the javascript.

Any help would be greatly appreciated. Thanks.


1 Answer 1


You can set this field in your ui-component

<field name="date">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">string</item>
                <item name="label" xsi:type="string" translate="true">Date</item>
                <item name="formElement" xsi:type="string">date</item>
                <item name="source" xsi:type="string">page</item>
                <item name="sortOrder" xsi:type="number">1</item>
                <item name="dataScope" xsi:type="string">date</item>
                <item name="options" xsi:type="array">
                    <item name="dateFormat" xsi:type="string">yyyy-MM-dd</item>
                    <item name="minDate" xsi:type="string">new Date()+ 1</item>
  • use <item name="minDate" xsi:type="string">new Date()</item> so today date also showing.
    – Devidas
    Sep 10, 2020 at 7:20

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.