I have enabled captcha using configuration STORES > Configuration > CUSTOMERS > Customer Configuration > Captcha
I am using one custom form which I used templates directly like below as I have to customize existing contact form on another page. [phtml file]
<?php echo
$this->getLayout()->createBlock('Magento\Contact\Block\ContactForm')
->setTemplate('Magento_Contact::contact_sticky.phtml')->toHtml();
?>
Captcha is showing on default page /contact but on my custom page, it is not showing.
contact_sticky.phtml
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<div class="block block-customer">
<div class="block-title">
<strong>
<span class="text"><?php echo __('Contact us') ?></span>
</strong>
</div>
<div class="block-content">
<form class="form contact"
action="<?php /* @escapeNotVerified */ echo $block->getFormAction(); ?>"
id="contact-form"
method="post"
data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>"
data-mage-init='{"validation":{}}'>
<fieldset class="fieldset contactus">
<div class="field name required">
<div class="control">
<input placeholder="<?php echo __('Your Name*')?>" name="name" id="name" title="<?php /* @escapeNotVerified */ echo __('Name') ?>" value="<?php echo $block->escapeHtml($this->helper('Magento\Contact\Helper\Data')->getUserName()) ?>" class="input-text" type="text" data-validate="{required:true}"/>
</div>
</div>
<div class="field email required">
<div class="control">
<input placeholder="<?php echo __('Your Email*')?>" name="email" id="email" title="<?php /* @escapeNotVerified */ echo __('Email') ?>" value="<?php echo $block->escapeHtml($this->helper('Magento\Contact\Helper\Data')->getUserEmail()) ?>" class="input-text" type="email" data-validate="{required:true, 'validate-email':true}"/>
</div>
</div>
<div class="field telephone">
<div class="control">
<input placeholder="<?php echo __('Your Phone')?>" name="telephone" id="telephone" title="<?php /* @escapeNotVerified */ echo __('Phone Number') ?>" value="" class="input-text" type="text" />
</div>
</div>
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('contact-additional-fields')->toHtml();?>
<div class="field comment required">
<div class="control">
<textarea placeholder="<?php echo __('Your Message*')?>" name="comment" id="comment" title="<?php /* @escapeNotVerified */ echo __('What’s on your mind?') ?>" class="input-text" cols="5" rows="3" data-validate="{required:true}"></textarea>
</div>
</div>
<?php echo $block->getChildHtml('form.additional.info'); ?>
</fieldset>
<div class="actions-toolbar">
<div class="primary">
<input type="hidden" name="hideit" id="hideit" value="" />
<button type="submit" title="<?php /* @escapeNotVerified */ echo __('Send Message') ?>" class="action submit primary">
<span><?php /* @escapeNotVerified */ echo __('Send Message') ?></span>
</button>
</div>
</div>
</form>
</div>
</div>