Magento2: Add validation in dynamic text box?Magento2, add to cart modalShipping Address validationSet dateFormat in date_range_min validation rule of Magento 2How to add dynamic radio buttons in custom checkout step in Magento2?Validation in product Customizable options?How to custom fields add while fetch V1/invoices API in magento2?Magento 2 Add Custom Dynamic Link in Customer NavigationCustom field validation in magento2How to get the payment details in magento2How to add custom validation for admin form in Magento 2?
PlotLabels with equations not expressions
How to write cleanly even if my character uses expletive language?
Current sense amp + op-amp buffer + ADC: Measuring down to 0 with single supply
Ban on all campaign finance?
How to make healing in an exploration game interesting
Do I need life insurance if I can cover my own funeral costs?
Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?
Life insurance that covers only simultaneous/dual deaths
Is a lawful good "antagonist" effective?
Dot in front of file
Sword in the Stone story where the sword was held in place by electromagnets
Where is the 1/8 CR apprentice in Volo's Guide to Monsters?
Is having access to past exams cheating and, if yes, could it be proven just by a good grade?
Did CPM support custom hardware using device drivers?
How do I interpret this "sky cover" chart?
Calculus II Professor will not accept my correct integral evaluation that uses a different method, should I bring this up further?
Why doesn't using two cd commands in bash script execute the second command?
Identifying the interval from A♭ to D♯
PTIJ: Who should pay for Uber rides: the child or the parent?
An Accountant Seeks the Help of a Mathematician
What is the greatest age difference between a married couple in Tanach?
Why would a flight no longer considered airworthy be redirected like this?
Why must traveling waves have the same amplitude to form a standing wave?
Importance of differentiation
Magento2: Add validation in dynamic text box?
Magento2, add to cart modalShipping Address validationSet dateFormat in date_range_min validation rule of Magento 2How to add dynamic radio buttons in custom checkout step in Magento2?Validation in product Customizable options?How to custom fields add while fetch V1/invoices API in magento2?Magento 2 Add Custom Dynamic Link in Customer NavigationCustom field validation in magento2How to get the payment details in magento2How to add custom validation for admin form in Magento 2?
I have added dynamic text box in admin category form.
I want to validate text box must contain 4 comma separate values.
phtml file:
<?php
$_htmlId = 'categorymodel';
$_htmlClass = 'input-text admin__control-text required-entry _required';
$_htmlName = 'model_information';
?>
<div class="control">
<tr id="attribute-options-table">
<td colspan="10" class="data-grid">
<table class="admin__control-table tiers_table" id="tiers_table">
<tbody id="<?= /* @escapeNotVerified */
$_htmlId ?>_container"></tbody>
<tfoot>
<tr>
<td colspan="4" class="a-right" id="modelAddButton">
<button id="modelAddButton" title="Add New Model" type="button"
class="action-default scalable add" data-ui-id="additional-info-add-button">
<span>Add New Model</span>
</button>
</td>
</tr>
</tfoot>
</table>
</td>
</tr>
<script>
require([
'jquery',
'mage/template',
"jquery/ui",
'jquery/validate',
'mage/mage',
"prototype"
], function (jQuery, mageTemplate) {
var modelRowTemplate = '<tr>'
+ '<td><input type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_id]" value="" id="models_index_model_id" data-form-part="category_form" />'
+ '<input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_name]" value="" id="models_index_model_name" /></td>'
+ '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-sku" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][sku_list]" value="" id="models_index_sku_list" /></td>'
// + '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="file" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][image]" value="" id="models_index_image" /></td>'
+ '<td class="last"><input data-form-part="category_form" type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][delete]" class="delete" value="" id="models_index_delete" />'
+ '<button title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Delete Model')) ?>" type="button" class="scalable delete icon-btn delete-product-option" id="models_index_delete_button" onclick="return modelControl.deleteItem(event);">'
+ '<span><span><span><?= /* @escapeNotVerified */ __("Delete") ?></span></span></span></button></td>'
+ '</tr>';
var modelControl = \r;
jQuery("#modelAddButton").on("click", function ()
modelControl.addItem();
);
//if(jQuery("button").hasClass("save"))
// jQuery("#save").on("click", function ()
//
// console.log("sdfsf");
//
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// console.log("eror");
// event.preventDefault();
// jQuery('models_0_sku_list').after('<label for="models_0_sku_list" generated="true" class="mage-error" id="models_0_sku_list-error">sku required</label>');
//
// );
// jQuery.validator.addMethod('required-sku', function (v)
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// var result = skuList.length < 4;
// event.preventDefault();
// return !result;
//
//
// , jQuery.mage.__('Please enter your comment.'));
// jQuery("button[data-form-role="save"]").on("click", function ()
// console.log('sdf');
// );
<?php
if ($block->getCategoryModels()) :
foreach ($block->getCategoryModels() as $model)://echo "<pre>";print_r($model->getData());
?>
modelControl.addItem('<?php echo $model->getId() ?>', '<?php echo $model->getModelName() ?>', '<?php echo $model->getSkuList() ?>', '<?php echo $model->getImage() ?>');
<?php
endforeach;
endif;
?>
window.modelControl = modelControl;
);
</script>
</div>
How to do that ...
Thanks.
magento2.2.2 php-7.1
add a comment |
I have added dynamic text box in admin category form.
I want to validate text box must contain 4 comma separate values.
phtml file:
<?php
$_htmlId = 'categorymodel';
$_htmlClass = 'input-text admin__control-text required-entry _required';
$_htmlName = 'model_information';
?>
<div class="control">
<tr id="attribute-options-table">
<td colspan="10" class="data-grid">
<table class="admin__control-table tiers_table" id="tiers_table">
<tbody id="<?= /* @escapeNotVerified */
$_htmlId ?>_container"></tbody>
<tfoot>
<tr>
<td colspan="4" class="a-right" id="modelAddButton">
<button id="modelAddButton" title="Add New Model" type="button"
class="action-default scalable add" data-ui-id="additional-info-add-button">
<span>Add New Model</span>
</button>
</td>
</tr>
</tfoot>
</table>
</td>
</tr>
<script>
require([
'jquery',
'mage/template',
"jquery/ui",
'jquery/validate',
'mage/mage',
"prototype"
], function (jQuery, mageTemplate) {
var modelRowTemplate = '<tr>'
+ '<td><input type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_id]" value="" id="models_index_model_id" data-form-part="category_form" />'
+ '<input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_name]" value="" id="models_index_model_name" /></td>'
+ '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-sku" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][sku_list]" value="" id="models_index_sku_list" /></td>'
// + '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="file" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][image]" value="" id="models_index_image" /></td>'
+ '<td class="last"><input data-form-part="category_form" type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][delete]" class="delete" value="" id="models_index_delete" />'
+ '<button title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Delete Model')) ?>" type="button" class="scalable delete icon-btn delete-product-option" id="models_index_delete_button" onclick="return modelControl.deleteItem(event);">'
+ '<span><span><span><?= /* @escapeNotVerified */ __("Delete") ?></span></span></span></button></td>'
+ '</tr>';
var modelControl = \r;
jQuery("#modelAddButton").on("click", function ()
modelControl.addItem();
);
//if(jQuery("button").hasClass("save"))
// jQuery("#save").on("click", function ()
//
// console.log("sdfsf");
//
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// console.log("eror");
// event.preventDefault();
// jQuery('models_0_sku_list').after('<label for="models_0_sku_list" generated="true" class="mage-error" id="models_0_sku_list-error">sku required</label>');
//
// );
// jQuery.validator.addMethod('required-sku', function (v)
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// var result = skuList.length < 4;
// event.preventDefault();
// return !result;
//
//
// , jQuery.mage.__('Please enter your comment.'));
// jQuery("button[data-form-role="save"]").on("click", function ()
// console.log('sdf');
// );
<?php
if ($block->getCategoryModels()) :
foreach ($block->getCategoryModels() as $model)://echo "<pre>";print_r($model->getData());
?>
modelControl.addItem('<?php echo $model->getId() ?>', '<?php echo $model->getModelName() ?>', '<?php echo $model->getSkuList() ?>', '<?php echo $model->getImage() ?>');
<?php
endforeach;
endif;
?>
window.modelControl = modelControl;
);
</script>
</div>
How to do that ...
Thanks.
magento2.2.2 php-7.1
add a comment |
I have added dynamic text box in admin category form.
I want to validate text box must contain 4 comma separate values.
phtml file:
<?php
$_htmlId = 'categorymodel';
$_htmlClass = 'input-text admin__control-text required-entry _required';
$_htmlName = 'model_information';
?>
<div class="control">
<tr id="attribute-options-table">
<td colspan="10" class="data-grid">
<table class="admin__control-table tiers_table" id="tiers_table">
<tbody id="<?= /* @escapeNotVerified */
$_htmlId ?>_container"></tbody>
<tfoot>
<tr>
<td colspan="4" class="a-right" id="modelAddButton">
<button id="modelAddButton" title="Add New Model" type="button"
class="action-default scalable add" data-ui-id="additional-info-add-button">
<span>Add New Model</span>
</button>
</td>
</tr>
</tfoot>
</table>
</td>
</tr>
<script>
require([
'jquery',
'mage/template',
"jquery/ui",
'jquery/validate',
'mage/mage',
"prototype"
], function (jQuery, mageTemplate) {
var modelRowTemplate = '<tr>'
+ '<td><input type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_id]" value="" id="models_index_model_id" data-form-part="category_form" />'
+ '<input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_name]" value="" id="models_index_model_name" /></td>'
+ '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-sku" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][sku_list]" value="" id="models_index_sku_list" /></td>'
// + '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="file" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][image]" value="" id="models_index_image" /></td>'
+ '<td class="last"><input data-form-part="category_form" type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][delete]" class="delete" value="" id="models_index_delete" />'
+ '<button title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Delete Model')) ?>" type="button" class="scalable delete icon-btn delete-product-option" id="models_index_delete_button" onclick="return modelControl.deleteItem(event);">'
+ '<span><span><span><?= /* @escapeNotVerified */ __("Delete") ?></span></span></span></button></td>'
+ '</tr>';
var modelControl = \r;
jQuery("#modelAddButton").on("click", function ()
modelControl.addItem();
);
//if(jQuery("button").hasClass("save"))
// jQuery("#save").on("click", function ()
//
// console.log("sdfsf");
//
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// console.log("eror");
// event.preventDefault();
// jQuery('models_0_sku_list').after('<label for="models_0_sku_list" generated="true" class="mage-error" id="models_0_sku_list-error">sku required</label>');
//
// );
// jQuery.validator.addMethod('required-sku', function (v)
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// var result = skuList.length < 4;
// event.preventDefault();
// return !result;
//
//
// , jQuery.mage.__('Please enter your comment.'));
// jQuery("button[data-form-role="save"]").on("click", function ()
// console.log('sdf');
// );
<?php
if ($block->getCategoryModels()) :
foreach ($block->getCategoryModels() as $model)://echo "<pre>";print_r($model->getData());
?>
modelControl.addItem('<?php echo $model->getId() ?>', '<?php echo $model->getModelName() ?>', '<?php echo $model->getSkuList() ?>', '<?php echo $model->getImage() ?>');
<?php
endforeach;
endif;
?>
window.modelControl = modelControl;
);
</script>
</div>
How to do that ...
Thanks.
magento2.2.2 php-7.1
I have added dynamic text box in admin category form.
I want to validate text box must contain 4 comma separate values.
phtml file:
<?php
$_htmlId = 'categorymodel';
$_htmlClass = 'input-text admin__control-text required-entry _required';
$_htmlName = 'model_information';
?>
<div class="control">
<tr id="attribute-options-table">
<td colspan="10" class="data-grid">
<table class="admin__control-table tiers_table" id="tiers_table">
<tbody id="<?= /* @escapeNotVerified */
$_htmlId ?>_container"></tbody>
<tfoot>
<tr>
<td colspan="4" class="a-right" id="modelAddButton">
<button id="modelAddButton" title="Add New Model" type="button"
class="action-default scalable add" data-ui-id="additional-info-add-button">
<span>Add New Model</span>
</button>
</td>
</tr>
</tfoot>
</table>
</td>
</tr>
<script>
require([
'jquery',
'mage/template',
"jquery/ui",
'jquery/validate',
'mage/mage',
"prototype"
], function (jQuery, mageTemplate) {
var modelRowTemplate = '<tr>'
+ '<td><input type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_id]" value="" id="models_index_model_id" data-form-part="category_form" />'
+ '<input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][model_name]" value="" id="models_index_model_name" /></td>'
+ '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-sku" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][sku_list]" value="" id="models_index_sku_list" /></td>'
// + '<td><input data-form-part="category_form" class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" type="file" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][image]" value="" id="models_index_image" /></td>'
+ '<td class="last"><input data-form-part="category_form" type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[index][delete]" class="delete" value="" id="models_index_delete" />'
+ '<button title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Delete Model')) ?>" type="button" class="scalable delete icon-btn delete-product-option" id="models_index_delete_button" onclick="return modelControl.deleteItem(event);">'
+ '<span><span><span><?= /* @escapeNotVerified */ __("Delete") ?></span></span></span></button></td>'
+ '</tr>';
var modelControl = \r;
jQuery("#modelAddButton").on("click", function ()
modelControl.addItem();
);
//if(jQuery("button").hasClass("save"))
// jQuery("#save").on("click", function ()
//
// console.log("sdfsf");
//
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// console.log("eror");
// event.preventDefault();
// jQuery('models_0_sku_list').after('<label for="models_0_sku_list" generated="true" class="mage-error" id="models_0_sku_list-error">sku required</label>');
//
// );
// jQuery.validator.addMethod('required-sku', function (v)
// var skuList = $('models_0_sku_list').value.split(',');
// console.log(skuList.length);
// if(skuList.length != 5)
// var result = skuList.length < 4;
// event.preventDefault();
// return !result;
//
//
// , jQuery.mage.__('Please enter your comment.'));
// jQuery("button[data-form-role="save"]").on("click", function ()
// console.log('sdf');
// );
<?php
if ($block->getCategoryModels()) :
foreach ($block->getCategoryModels() as $model)://echo "<pre>";print_r($model->getData());
?>
modelControl.addItem('<?php echo $model->getId() ?>', '<?php echo $model->getModelName() ?>', '<?php echo $model->getSkuList() ?>', '<?php echo $model->getImage() ?>');
<?php
endforeach;
endif;
?>
window.modelControl = modelControl;
);
</script>
</div>
How to do that ...
Thanks.
magento2.2.2 php-7.1
magento2.2.2 php-7.1
asked 13 mins ago
Mano MMano M
979219
979219
add a comment |
add a comment |
0
active
oldest
votes
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%2f266031%2fmagento2-add-validation-in-dynamic-text-box%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f266031%2fmagento2-add-validation-in-dynamic-text-box%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