Could somebody help me to apply form validation directly in admin html files?
Here is my code for example:

<form method="post" id="commercial_invoice_create_form" name="commercial_invoice_create_form"  action="<?php echo $block->getUrl('adminhtml/commercialinvoice/save',['order_id' => $_order->getId()]);?>"'>
    <?php echo $block->getChildHtml('formkey-ci')?>

    <div class="field airway_billno required">
        <label class="label" for="airway_billno"><?php echo __('International Air Waybill Number') ?></label>
        <div class="control">
            <input name="airway_billno" id="airway_billno"
            title="International Air Waybill Number" class="input-text  required-entry _required"
            type="text" data-validate="{required:true}" aria-required="true">
    <button id="commercial_invoice_save_button" title="Submit Invoice" type="button" class="action-default scalable action-save action-secondary" data-ui-id="widget-button-0">
        <span>Submit Invoice</span>

    ], function($){
        $(document).ready(function () {
        $('#commercial_invoice_save_button').click(function () { // The button type should be "button" and not submit
            var dataForm = $('#commercial_invoice_create_form');
            var ignore = null;
            dataForm.mage('validation', {
                ignore: ignore ? ':hidden:not(' + ignore + ')' : ':hidden'
            }).find('input:text').attr('autocomplete', 'off');


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.