Asif Mehmood
Asif Mehmood

Reputation: 984

Max length of an input-tag of text type in html?

What is the maximum-length (i.e default value) max-length of input-value we are able to enter in the html element <input/> ?

Upvotes: 1

Views: 2585

Answers (2)

user2107435
user2107435

Reputation:

this simple code show you, how verify error ...

<!DOCTYPE html>
<html>
<body>
Username: <input type="text" id="x" maxlength="-1"><br>
<script>
    try
    {
        var x = document.getElementById("x").maxLength=-1;
    }
    catch(err) {
        document.write ( err.message );
    }
    document.write( "<br>" +x ) ;
</script>

</body>
</html>

Output :

Username: Failed to set the 'maxLength' property on 'HTMLInputElement': The value provided (-1) is negative. undefined

Upvotes: 0

user2107435
user2107435

Reputation:

max length is : 524288 ( default )

<input type="text" id="myText" maxlength="30000000000">
var x = document.getElementById("myText").maxLength;
document.write( x ) ;

show in browser : 524288

debug : Uncaught IndexSizeError: Failed to set the 'maxLength' property on 'HTMLInputElement': The value provided (-64771072) is negative.

Upvotes: 2

Related Questions