Android ignoring max length | WordPress.org

[ad_1]

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]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer