I added custom field in shipping method division on checkout page.

But i want to add validation on it.

So, how to add validations required and numeric to that field.

  • Could you please provide more detail. how you added input field on checkout page . – Dharmendra Jadav Jul 18 '18 at 12:37
<form class="" action="" id="" method="" data-hasrequired="* Required Fields">
    <fieldset class="">
        <div class="">
            <label class="" for="field1"><span>Field 1 (using data-validate)</span></label>
            <div class="control">
                        <input name="field1" id="field1" title="Field 1" value="" class="input-text" type="text" data-validate="{'validate-number':true}" />

Hope so this may help you,

there is some rule in Magento to validate input field that rules the state in "data-validate" attribute in field tag. You can validate the field for may restriction using this attribute. search for other validation rules, there are about 99 rules

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.