CheckableInputTypes.cpp (1151B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "mozilla/dom/CheckableInputTypes.h" 8 9 #include "mozilla/dom/HTMLInputElement.h" 10 11 using namespace mozilla; 12 using namespace mozilla::dom; 13 14 /* input type=checkbox */ 15 16 bool CheckboxInputType::IsValueMissing() const { 17 if (!mInputElement->IsRequired()) { 18 return false; 19 } 20 21 return !mInputElement->Checked(); 22 } 23 24 nsresult CheckboxInputType::GetValueMissingMessage(nsAString& aMessage) { 25 return nsContentUtils::GetMaybeLocalizedString( 26 nsContentUtils::eDOM_PROPERTIES, "FormValidationCheckboxMissing", 27 mInputElement->OwnerDoc(), aMessage); 28 } 29 30 /* input type=radio */ 31 32 nsresult RadioInputType::GetValueMissingMessage(nsAString& aMessage) { 33 return nsContentUtils::GetMaybeLocalizedString( 34 nsContentUtils::eDOM_PROPERTIES, "FormValidationRadioMissing", 35 mInputElement->OwnerDoc(), aMessage); 36 }