Question

magento 2 have Validation clases for admin forms Like this for integer. What is for floatting numbers like 12.00 or 23.33

        <item name="validate-integer" xsi:type="boolean">true</item>

Thanks for your valuable help

Was it helpful?

Solution

You can use pattern for validate numbers:

data-validate="{'required':true, 'pattern':/^\d+(\.\d{1,2})?$/, 'validate-greater-than-zero':true}"

You can validate form by below method:

<script>
    require(['jquery'], function($) {
        $(function() {
            $('#your-form-id').submit(function() {
                if($('#your-form-id').valid()) {
                    //your further code
                }
                return false;
            });
        });
    });
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top