sharad harpanahalli
sharad harpanahalli

Reputation: 35

iOS Safari ignores HTML 'maxlength' attribute

i am using below line of code to restrict the user but not working for iphone maxlength ="4";

<input type="number" name="securitycode"  id="securityCode" maxlength="4" />

Is there any way to enforce this on iOS?

Upvotes: 2

Views: 2894

Answers (1)

Mate Hegedus
Mate Hegedus

Reputation: 2905

This is a known issue. One work around is to use jQuery to restrict this.

$('input[name="securitycode"]').keypress(function() {
    if (this.value.length >= 4) {
        return false;
    }
});

Upvotes: 1

Related Questions