2

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.

3

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>
                </item>
            </item>
        </argument>
</field>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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