magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.52k stars 9.31k forks source link

Missing validation message in custom date form field #38611

Open hiren-gujarati opened 6 months ago

hiren-gujarati commented 6 months ago

Preconditions and environment

Steps to reproduce

  1. Add custom date field with date button in frontend form.
  2. Open form which have custom date field.
  3. Try to submit blank form.
  4. All field show validation message as per there validation but date field not show any validation message

You can add custom date form field without calendar button using following code snippets,

<div class="field required">
    <label for="establishment_date" class="label">
        <span><?= /* @noEscape */ $block->escapeHtml(__('Establishment Date')) ?></span>
    </label>
    <div class="control">
        <input type="text"
                name="establishment_date"
                value=""
                title="<?= /* @noEscape */ $block->escapeHtml(__('Establishment Date')) ?>"
                class="input-text required-entry"
                id="establishment_date">
    </div>
</div>
<script type="text/javascript">
    require([
        'jquery',
        'mage/calendar'
    ], function ($) {
        $("#establishment_date").datepicker({
            dateFormat:'dd-mm-yy',
            changeYear: true,
            changeMonth: true,
        });
    });
</script>

Expected result

Date form field should show validation message same as other fields

image

Actual result

Date field not showing validation message without calendar button

image

Additional information

image

Error message is placed after button for date field from validation.js https://github.com/magento/magento2/blob/2.4-develop/lib/web/mage/validation.js#L1880-L1883

Release note

No response

Triage and priority

m2-assistant[bot] commented 6 months ago

Hi @hiren-gujarati. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 6 months ago

Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:


m2-assistant[bot] commented 6 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 6 months ago

Hello @hiren-gujarati,

Thank you for the report and collaboration!

Verified this on 2.4-develop. The date-picker validation error is thrown only if the button is enabled, if the button is disabled even though the field is empty the error is not shown.

Please take a look at the screenshot:

image

Hence confirming this issue.

Thank you.

github-jira-sync-bot commented 6 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-11800 is successfully created for this GitHub issue.

m2-assistant[bot] commented 6 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.