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?













0















I have added dynamic text box in admin category form.



I want to validate text box must contain 4 comma separate values.



enter image description here



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.










share|improve this question


























    0















    I have added dynamic text box in admin category form.



    I want to validate text box must contain 4 comma separate values.



    enter image description here



    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.










    share|improve this question
























      0












      0








      0








      I have added dynamic text box in admin category form.



      I want to validate text box must contain 4 comma separate values.



      enter image description here



      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.










      share|improve this question














      I have added dynamic text box in admin category form.



      I want to validate text box must contain 4 comma separate values.



      enter image description here



      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 13 mins ago









      Mano MMano M

      979219




      979219




















          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
          );



          );













          draft saved

          draft discarded


















          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















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2