• Resolved kayvee111

    (@kayvee111)


    We have a issue with an android samsung phone (S22) – we need 3 characters max to be entered into a field (its the first part of a post code so it will be g1 or g44 for example) – this works fine. the text field id is #fieldname1 and its sent to a min length of 2 & a max of 3 – which works on ios/desktop/all devices I can check & test this on – but it ignores the max length on the clients Samsung android based phone

    I have googled & there is a know android bug which ignores the max length and allows any amount of characters to be added.

    I don’t have access to a device this happens on – but I have videos from the users showing the issue – I also cant replicate it on the Samsung developers lab either (i.e I was trying various Samsung phones to test this on) .

    I have found various pieces of javascript which can force this – but I am not familar enough with javscript to know if what I have added is correct – & I also cant check…


    Would this work? & can anyone check & test this?

    $(document).ready(function() {
            $('#fieldname1').keypress(function() {
                if ($(this).val().length === $(this).attr('maxlength')) {
                    return false;


    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @kayvee111

    Thank you very much for using our plugin. Please insert an HTML Content field in the form and enter the following piece of code as its content:

    <script>
    jQuery(document).on('keydown', '#fbuilder input', function(){
    
    let $ = jQuery, 
    e = $(this), 
    m = e.attr('maxlength'), 
    v = String(e.val()), 
    l = e.length;
    
    if( m && m < l) {
    e.val(v.substring(0,m));
    return false;
    }
    
    });
    </script>

    It is a more general solution that covers every field in the form with a maxlength attribute. Note that Android Chrome triggers the events after we let off typing.

    Best regards.

    Thread Starter kayvee111

    (@kayvee111)

    Thank you so much!!! – I have added that in as the first field will go and try & get in touch with the client & get them to check. (i wish the samsung lab actually matched what happens on a mobile!!)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Android ignoring max length’ is closed to new replies.