Bruno Follon
Bruno Follon

Reputation: 412

Input maxlength attribute ignored when inserting value with val(someValue)

I've been trying to insert a value into an HTML input like so:

$("#someID").val($("#anotherID").html());

The problem being that $("#anotherID").html() is longer than the default value of 524288

Specifically, the length is 602221

I've set the maxlength attibute to 52428800 but it seems to be ignored. The value is trimmed and the length of it is spot on 524288, which makes me think it simply doesn't work.

This is what I get when I check someID on the console:

$("#someID")
[<input class=​"hidden" id=​"someID" type=​"text" name=​"someID" maxlength=​"52428800">​]

Am I doing something wrong? The attribute seems to be set.

EDIT: I'm using chrome, and it seems that the maxlength attribute cannot be increased over 524288

Upvotes: 2

Views: 943

Answers (1)

Bilk
Bilk

Reputation: 438

It seems that there is no standard limit, but the one that every browser implements (and you can't raise it via javascript). See the following answer:

https://stackoverflow.com/a/26016746/3697452

Upvotes: 1

Related Questions