Input Number max Attribute

Definition and Usage

max properties to set or return the value of the max attribute of a numeric field.

The HTML max attribute specifies the maximum value of a numeric field.

Tip:Use the max attribute and min properties to create a valid value range.

Tip:To set or return the value of the min attribute, use min attribute.

See also:

HTML Reference Manual:HTML <input> max Attribute

Example

Example 1

Get the maximum allowed value of the numeric field:

var x = document.getElementById("myNumber").max;

Try it yourself

Example 2

Change the maximum value:

document.getElementById("myNumber").max = "10";

Try it yourself

Syntax

Return the max attribute:

numberObject.max

Set max attribute:

numberObject.max = number

Attribute Value

Value Description
number Specify the maximum allowed value.

Technical Details

Return Value: A string value that represents the maximum allowed number.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support