diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index c23f73f3220..4ce74d29cde 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -630,7 +630,7 @@ impl VirtualMethods for HTMLInputElement {
&atom!("name") => AttrValue::from_atomic(value),
&atom!("size") => AttrValue::from_limited_u32(value, DEFAULT_INPUT_SIZE),
&atom!("type") => AttrValue::from_atomic(value),
- &atom!("maxlength") => AttrValue::from_i32(value, i32::MAX),
+ &atom!("maxlength") => AttrValue::from_limited_i32(value, DEFAULT_MAX_LENGTH),
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
}
}