String ColorInputType::sanitizeValue(const String& proposedValue) const { if (!isValidColorString(proposedValue)) return fallbackValue(); return proposedValue.lower(); }
bool ValidityState::typeMismatch() const { if (!m_control->hasTagName(inputTag)) return false; HTMLInputElement* input = static_cast<HTMLInputElement*>(m_control); String value = input->value(); if (value.isEmpty()) return false; switch (input->inputType()) { case HTMLInputElement::COLOR: return !isValidColorString(value); case HTMLInputElement::NUMBER: return !parseToDoubleForNumberType(value, 0); case HTMLInputElement::URL: return !KURL(KURL(), value).isValid(); case HTMLInputElement::EMAIL: { if (!input->multiple()) return !isValidEmailAddress(value); Vector<String> addresses; value.split(',', addresses); for (unsigned i = 0; i < addresses.size(); ++i) { if (!isValidEmailAddress(addresses[i])) return true; } return false; } case HTMLInputElement::DATE: case HTMLInputElement::DATETIME: case HTMLInputElement::DATETIMELOCAL: case HTMLInputElement::MONTH: case HTMLInputElement::TIME: case HTMLInputElement::WEEK: return !HTMLInputElement::parseToDateComponents(input->inputType(), value, 0); case HTMLInputElement::BUTTON: case HTMLInputElement::CHECKBOX: case HTMLInputElement::FILE: case HTMLInputElement::HIDDEN: case HTMLInputElement::IMAGE: case HTMLInputElement::ISINDEX: case HTMLInputElement::PASSWORD: case HTMLInputElement::RADIO: case HTMLInputElement::RANGE: case HTMLInputElement::RESET: case HTMLInputElement::SEARCH: case HTMLInputElement::SUBMIT: case HTMLInputElement::TELEPHONE: // FIXME: Is there validation for <input type=telephone>? case HTMLInputElement::TEXT: return false; } ASSERT_NOT_REACHED(); return false; }