2

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

Bilk
  • 418
  • 6
  • 19
Bruno Follon
  • 422
  • 3
  • 13
  • 1
    From MDN: `The constraint is evaluated only when the value of the attribute has been changed.` Programmatically changing the value does not raise a change event - I would suggest doing this manually after setting the `val()` via `.change()` – Rory McCrossan Oct 27 '14 at 14:31
  • @RoryMcCrossan I've tried what you said calling `.change()` after `$("#someID").val($("#anotherID").html());` and the length is now 1 and the value is still the same. I must be doing something wrong. – Bruno Follon Oct 27 '14 at 14:40

1 Answers1

1

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

Community
  • 1
  • 1
Bilk
  • 418
  • 6
  • 19