Index: Source/core/html/forms/BaseTextInputType.cpp |
diff --git a/Source/core/html/forms/BaseTextInputType.cpp b/Source/core/html/forms/BaseTextInputType.cpp |
index 9ee4ab54e517401cb94de4ff6f30f0ff78f1f01a..fe85c790e33418ca356b201e4ecfbf0c25fe9f0a 100644 |
--- a/Source/core/html/forms/BaseTextInputType.cpp |
+++ b/Source/core/html/forms/BaseTextInputType.cpp |
@@ -37,6 +37,11 @@ int BaseTextInputType::maxLength() const |
return element().maxLength(); |
} |
+int BaseTextInputType::minLength() const |
+{ |
+ return element().minLength(); |
+} |
+ |
bool BaseTextInputType::tooLong(const String& value, HTMLTextFormControlElement::NeedsToCheckDirtyFlag check) const |
{ |
int max = element().maxLength(); |
@@ -51,6 +56,22 @@ bool BaseTextInputType::tooLong(const String& value, HTMLTextFormControlElement: |
return value.length() > static_cast<unsigned>(max); |
} |
+bool BaseTextInputType::tooShort(const String& value, HTMLTextFormControlElement::NeedsToCheckDirtyFlag check) const |
+{ |
+ int min = element().minLength(); |
+ if (min <= 0) |
+ return false; |
+ if (check == HTMLTextFormControlElement::CheckDirtyFlag) { |
+ // Return false for the default value or a value set by a script even if |
+ // it is shorter than minLength. |
+ if (!element().hasDirtyValue() || !element().lastChangeWasUserEdit()) |
+ return false; |
+ } |
+ // An empty string is excluded from minlength check. |
+ unsigned len = value.length(); |
+ return len > 0 && len < static_cast<unsigned>(min); |
+} |
+ |
bool BaseTextInputType::patternMismatch(const String& value) const |
{ |
const AtomicString& rawPattern = element().fastGetAttribute(patternAttr); |