0

I am trying to make captcha input label a placeholder, not label.

I followed the following instructions for doing the same thing on the checkout:
https://diweirich.com/magento-2-using-placeholders-in-form-fields/ Add placeholder and remove all labels in Magento 2 Checkout.

But it doesn't affect the captcha input field. Can any suggest where I need to edit to achieve a placeholder as opposed to label for the captcha input field?

2 Answers 2

0

=> Copy :

/vendor/magento/module-captcha/view/frontend/templates/default.phtml

=> to :

/app/design/frontend/{vendor}/{theme}/Magento_Captcha/templates/

=> Remove :

<label for="captcha_<?= $block->escapeHtmlAttr($block->getFormId()) ?>" class="label"><span><?= $block->escapeHtml(__('Please type the letters below')) ?></span></label>

and add a placeholder to the input element:

<input name="<?= $block->escapeHtmlAttr(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE) ?>[<?= $block->escapeHtmlAttr($block->getFormId()) ?>]" type="text" class="input-text required-entry" data-validate="{required:true}" id="captcha_<?= $block->escapeHtmlAttr($block->getFormId()) ?>" placeholder="<?= $block->escapeHtml(__('Please type the letters above')) ?>" />

Clear static files and cache to see the changes.

0

Just Add this Following Script, This will solve your problem.

<script type="text/javascript">
require(['jquery'], function ($) 
{
    $(document).ready(function () 
    {
        $("label:contains('Please type captcha here')").hide();
        $(#Your_Form_ID).find('input[name*="captcha"]').attr("placeholder", "Please type captcha here");
    })
});
</script>

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.