1

How to add new html attribute maxlength="10" to street input field on shipping address form.

Thanks

4
  • do you want all Street Address input feilds ? Commented Sep 16, 2019 at 8:58
  • yes for 2 street fields Commented Sep 16, 2019 at 8:59
  • You can check with this answer, Adding maxlength to street
    – aravind
    Commented Sep 16, 2019 at 9:06
  • @aravind i want html attribut maxlength not validation max_lenght Commented Sep 16, 2019 at 9:17

1 Answer 1

1

I achieved this with below code

require(['jquery', 'jquery/ui'], function($){
    jQuery(document).ready( function() {
        var existConditionZero = setInterval(function() {
            if (jQuery("input[name='street[0]']").length > 0) { 
                clearInterval(existConditionZero);
                runMyFunctionZero();
            }
        }, 100);
        function runMyFunctionZero(){
            jQuery('input[name="street[0]"]').attr("maxlength","10");
        }
    });
});

require(['jquery', 'jquery/ui'], function($){
    jQuery(document).ready( function() {
        var existConditionOne = setInterval(function() {
            if (jQuery("input[name='street[1]']").length > 0) { 
                clearInterval(existConditionOne);
                runMyFunctionOne();
            }
        }, 100);
        function runMyFunctionOne(){
            jQuery('input[name="street[1]"]').attr("maxlength","10");
        }
    });
});

Your Answer

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

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