How to add custom checkbox with event in customer registration Magento 2?before submit a form atleast one checkboxes is requiredAdd Checkbox In Magento 2 Admin FormMagento 2 add custom product attribute validation from install scriptTo add one single validation for checkbox group and input fieldWhat is the proper format for checkbox validation in Magento 2?Magento 2 Add new field to Magento_User admin formUI component hidden input on checkout addressValidate form field on perticular action in Magento 2how to add category using factory method not object managerMagento 2 : How to keep the custom form fields filled in case of validation error Magento 2
Why does the integral domain "being trapped between a finite field extension" implies that it is a field?
Transformation of random variables and joint distributions
Is there a word to describe the feeling of being transfixed out of horror?
Longest common substring in linear time
Diode in opposite direction?
My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?
Did US corporations pay demonstrators in the German demonstrations against article 13?
Divine apple island
Can I rely on this github repository files?
Using a siddur to Daven from in a seforim store
We have a love-hate relationship
Could solar power be utilized and substitute coal in the 19th century?
Has Darkwing Duck ever met Scrooge McDuck?
Greco-Roman egalitarianism
A Permanent Norse Presence in America
Fly on a jet pack vs fly with a jet pack?
What does this horizontal bar at the first measure mean?
Would it be legal for a US State to ban exports of a natural resource?
Visiting the UK as unmarried couple
Some numbers are more equivalent than others
How do I implement a file system driver driver in Linux?
On a tidally locked planet, would time be quantized?
Is camera lens focus an exact point or a range?
A social experiment. What is the worst that can happen?
How to add custom checkbox with event in customer registration Magento 2?
before submit a form atleast one checkboxes is requiredAdd Checkbox In Magento 2 Admin FormMagento 2 add custom product attribute validation from install scriptTo add one single validation for checkbox group and input fieldWhat is the proper format for checkbox validation in Magento 2?Magento 2 Add new field to Magento_User admin formUI component hidden input on checkout addressValidate form field on perticular action in Magento 2how to add category using factory method not object managerMagento 2 : How to keep the custom form fields filled in case of validation error Magento 2
I'm working on creating a custom checkbox with an event
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
1)when the checkbox is ticked need to show
extra two fields in customer registration
2)How I change the checkbox as optional one
How I can do it ???
Any ideas?
Edit 1:
addtional.phtml
<div id="idofyourinputwrapper">
<div class="field skype required">
<label class="label" for="skype2">
<span><?= $block->escapeHtml(__('Check now')) ?></span>
</label>
<div class="control">
<input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false">
</div>
</div>
</div>
magento2 javascript custom-field checkbox
add a comment |
I'm working on creating a custom checkbox with an event
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
1)when the checkbox is ticked need to show
extra two fields in customer registration
2)How I change the checkbox as optional one
How I can do it ???
Any ideas?
Edit 1:
addtional.phtml
<div id="idofyourinputwrapper">
<div class="field skype required">
<label class="label" for="skype2">
<span><?= $block->escapeHtml(__('Check now')) ?></span>
</label>
<div class="control">
<input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false">
</div>
</div>
</div>
magento2 javascript custom-field checkbox
hm wait..........
– prabhakaran7
Mar 16 at 7:42
add a comment |
I'm working on creating a custom checkbox with an event
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
1)when the checkbox is ticked need to show
extra two fields in customer registration
2)How I change the checkbox as optional one
How I can do it ???
Any ideas?
Edit 1:
addtional.phtml
<div id="idofyourinputwrapper">
<div class="field skype required">
<label class="label" for="skype2">
<span><?= $block->escapeHtml(__('Check now')) ?></span>
</label>
<div class="control">
<input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false">
</div>
</div>
</div>
magento2 javascript custom-field checkbox
I'm working on creating a custom checkbox with an event
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
1)when the checkbox is ticked need to show
extra two fields in customer registration
2)How I change the checkbox as optional one
How I can do it ???
Any ideas?
Edit 1:
addtional.phtml
<div id="idofyourinputwrapper">
<div class="field skype required">
<label class="label" for="skype2">
<span><?= $block->escapeHtml(__('Check now')) ?></span>
</label>
<div class="control">
<input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false">
</div>
</div>
</div>
magento2 javascript custom-field checkbox
magento2 javascript custom-field checkbox
edited Mar 16 at 8:29
prabhakaran7
asked Mar 16 at 6:12
prabhakaran7prabhakaran7
1969
1969
hm wait..........
– prabhakaran7
Mar 16 at 7:42
add a comment |
hm wait..........
– prabhakaran7
Mar 16 at 7:42
hm wait..........
– prabhakaran7
Mar 16 at 7:42
hm wait..........
– prabhakaran7
Mar 16 at 7:42
add a comment |
2 Answers
2
active
oldest
votes
Try this,
Replace this
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
with this
<div class="field tcagreecreateaccount">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" class="input-checkbox checkbox" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
then add the below script in your phtml
require(['jquery'],function($)
$(document).ready(function ()
var ckbox = $('#tcagreecreateaccount');
$('#tcagreecreateaccount').on('click',function ()
if (ckbox.is(':checked'))
$('#idofyourinputwrapper').show(); //idofyourinputwrapper is your input wrapper
else
$('#idofyourinputwrapper').hide();
);
);
);
wrap your two inputs with a div like below.
<div id="idofyourinputwrapper">
Hope this helps :)
i tried but not event working....
– prabhakaran7
Mar 16 at 7:57
Event?? what that mean? The above code do, remove required field and when you click checkbox it will show and hide the below field. Please update your code
– Prathap Gunasekaran
Mar 16 at 8:00
i added this not working <div id="idofyourinputwrapper"> <div class="field skype required"> <label class="label" for="skype2"> <span><?= $block->escapeHtml(__('Check now')) ?></span> </label> <div class="control"> <input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false"> </div> </div> </div>
– prabhakaran7
Mar 16 at 8:05
i set is required:false
– prabhakaran7
Mar 16 at 8:06
Have you added script ??
– Prathap Gunasekaran
Mar 16 at 8:07
|
show 10 more comments
Firstly remove required from your checkbox and other two attributes.
Both attributes depending on checkbox click will be hidden by default (can do with CSS or JS).
On checkbox click, you can use jQuery to display both attributes.
done.........................
– prabhakaran7
Mar 16 at 10:41
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266159%2fhow-to-add-custom-checkbox-with-event-in-customer-registration-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this,
Replace this
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
with this
<div class="field tcagreecreateaccount">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" class="input-checkbox checkbox" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
then add the below script in your phtml
require(['jquery'],function($)
$(document).ready(function ()
var ckbox = $('#tcagreecreateaccount');
$('#tcagreecreateaccount').on('click',function ()
if (ckbox.is(':checked'))
$('#idofyourinputwrapper').show(); //idofyourinputwrapper is your input wrapper
else
$('#idofyourinputwrapper').hide();
);
);
);
wrap your two inputs with a div like below.
<div id="idofyourinputwrapper">
Hope this helps :)
i tried but not event working....
– prabhakaran7
Mar 16 at 7:57
Event?? what that mean? The above code do, remove required field and when you click checkbox it will show and hide the below field. Please update your code
– Prathap Gunasekaran
Mar 16 at 8:00
i added this not working <div id="idofyourinputwrapper"> <div class="field skype required"> <label class="label" for="skype2"> <span><?= $block->escapeHtml(__('Check now')) ?></span> </label> <div class="control"> <input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false"> </div> </div> </div>
– prabhakaran7
Mar 16 at 8:05
i set is required:false
– prabhakaran7
Mar 16 at 8:06
Have you added script ??
– Prathap Gunasekaran
Mar 16 at 8:07
|
show 10 more comments
Try this,
Replace this
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
with this
<div class="field tcagreecreateaccount">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" class="input-checkbox checkbox" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
then add the below script in your phtml
require(['jquery'],function($)
$(document).ready(function ()
var ckbox = $('#tcagreecreateaccount');
$('#tcagreecreateaccount').on('click',function ()
if (ckbox.is(':checked'))
$('#idofyourinputwrapper').show(); //idofyourinputwrapper is your input wrapper
else
$('#idofyourinputwrapper').hide();
);
);
);
wrap your two inputs with a div like below.
<div id="idofyourinputwrapper">
Hope this helps :)
i tried but not event working....
– prabhakaran7
Mar 16 at 7:57
Event?? what that mean? The above code do, remove required field and when you click checkbox it will show and hide the below field. Please update your code
– Prathap Gunasekaran
Mar 16 at 8:00
i added this not working <div id="idofyourinputwrapper"> <div class="field skype required"> <label class="label" for="skype2"> <span><?= $block->escapeHtml(__('Check now')) ?></span> </label> <div class="control"> <input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false"> </div> </div> </div>
– prabhakaran7
Mar 16 at 8:05
i set is required:false
– prabhakaran7
Mar 16 at 8:06
Have you added script ??
– Prathap Gunasekaran
Mar 16 at 8:07
|
show 10 more comments
Try this,
Replace this
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
with this
<div class="field tcagreecreateaccount">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" class="input-checkbox checkbox" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
then add the below script in your phtml
require(['jquery'],function($)
$(document).ready(function ()
var ckbox = $('#tcagreecreateaccount');
$('#tcagreecreateaccount').on('click',function ()
if (ckbox.is(':checked'))
$('#idofyourinputwrapper').show(); //idofyourinputwrapper is your input wrapper
else
$('#idofyourinputwrapper').hide();
);
);
);
wrap your two inputs with a div like below.
<div id="idofyourinputwrapper">
Hope this helps :)
Try this,
Replace this
<div class="field tcagreecreateaccount required">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" data-validate="required:false" class="input-checkbox checkbox required" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
with this
<div class="field tcagreecreateaccount">
<div class="control">
<input type="checkbox" id="tcagreecreateaccount" name="tcagreecreateaccount" class="input-checkbox checkbox" value="1">
<label for="tcagreecreateaccount" class="label">
<?= __('Custom checkbox') ?>
</label>
</div>
</div>
then add the below script in your phtml
require(['jquery'],function($)
$(document).ready(function ()
var ckbox = $('#tcagreecreateaccount');
$('#tcagreecreateaccount').on('click',function ()
if (ckbox.is(':checked'))
$('#idofyourinputwrapper').show(); //idofyourinputwrapper is your input wrapper
else
$('#idofyourinputwrapper').hide();
);
);
);
wrap your two inputs with a div like below.
<div id="idofyourinputwrapper">
Hope this helps :)
edited Mar 16 at 10:01
answered Mar 16 at 7:29
Prathap GunasekaranPrathap Gunasekaran
1,4071617
1,4071617
i tried but not event working....
– prabhakaran7
Mar 16 at 7:57
Event?? what that mean? The above code do, remove required field and when you click checkbox it will show and hide the below field. Please update your code
– Prathap Gunasekaran
Mar 16 at 8:00
i added this not working <div id="idofyourinputwrapper"> <div class="field skype required"> <label class="label" for="skype2"> <span><?= $block->escapeHtml(__('Check now')) ?></span> </label> <div class="control"> <input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false"> </div> </div> </div>
– prabhakaran7
Mar 16 at 8:05
i set is required:false
– prabhakaran7
Mar 16 at 8:06
Have you added script ??
– Prathap Gunasekaran
Mar 16 at 8:07
|
show 10 more comments
i tried but not event working....
– prabhakaran7
Mar 16 at 7:57
Event?? what that mean? The above code do, remove required field and when you click checkbox it will show and hide the below field. Please update your code
– Prathap Gunasekaran
Mar 16 at 8:00
i added this not working <div id="idofyourinputwrapper"> <div class="field skype required"> <label class="label" for="skype2"> <span><?= $block->escapeHtml(__('Check now')) ?></span> </label> <div class="control"> <input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false"> </div> </div> </div>
– prabhakaran7
Mar 16 at 8:05
i set is required:false
– prabhakaran7
Mar 16 at 8:06
Have you added script ??
– Prathap Gunasekaran
Mar 16 at 8:07
i tried but not event working....
– prabhakaran7
Mar 16 at 7:57
i tried but not event working....
– prabhakaran7
Mar 16 at 7:57
Event?? what that mean? The above code do, remove required field and when you click checkbox it will show and hide the below field. Please update your code
– Prathap Gunasekaran
Mar 16 at 8:00
Event?? what that mean? The above code do, remove required field and when you click checkbox it will show and hide the below field. Please update your code
– Prathap Gunasekaran
Mar 16 at 8:00
i added this not working <div id="idofyourinputwrapper"> <div class="field skype required"> <label class="label" for="skype2"> <span><?= $block->escapeHtml(__('Check now')) ?></span> </label> <div class="control"> <input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false"> </div> </div> </div>
– prabhakaran7
Mar 16 at 8:05
i added this not working <div id="idofyourinputwrapper"> <div class="field skype required"> <label class="label" for="skype2"> <span><?= $block->escapeHtml(__('Check now')) ?></span> </label> <div class="control"> <input type="text" name="skype2" id="skype22" value="" title="<?= $block->escapeHtmlAttr(__('Check now')) ?>" class="input-text" data-validate="required:false"> </div> </div> </div>
– prabhakaran7
Mar 16 at 8:05
i set is required:false
– prabhakaran7
Mar 16 at 8:06
i set is required:false
– prabhakaran7
Mar 16 at 8:06
Have you added script ??
– Prathap Gunasekaran
Mar 16 at 8:07
Have you added script ??
– Prathap Gunasekaran
Mar 16 at 8:07
|
show 10 more comments
Firstly remove required from your checkbox and other two attributes.
Both attributes depending on checkbox click will be hidden by default (can do with CSS or JS).
On checkbox click, you can use jQuery to display both attributes.
done.........................
– prabhakaran7
Mar 16 at 10:41
add a comment |
Firstly remove required from your checkbox and other two attributes.
Both attributes depending on checkbox click will be hidden by default (can do with CSS or JS).
On checkbox click, you can use jQuery to display both attributes.
done.........................
– prabhakaran7
Mar 16 at 10:41
add a comment |
Firstly remove required from your checkbox and other two attributes.
Both attributes depending on checkbox click will be hidden by default (can do with CSS or JS).
On checkbox click, you can use jQuery to display both attributes.
Firstly remove required from your checkbox and other two attributes.
Both attributes depending on checkbox click will be hidden by default (can do with CSS or JS).
On checkbox click, you can use jQuery to display both attributes.
answered Mar 16 at 6:47
Amrit Pal SinghAmrit Pal Singh
781523
781523
done.........................
– prabhakaran7
Mar 16 at 10:41
add a comment |
done.........................
– prabhakaran7
Mar 16 at 10:41
done.........................
– prabhakaran7
Mar 16 at 10:41
done.........................
– prabhakaran7
Mar 16 at 10:41
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f266159%2fhow-to-add-custom-checkbox-with-event-in-customer-registration-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
hm wait..........
– prabhakaran7
Mar 16 at 7:42