Commit 68df4e47 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1753233 - Add missing bad input messages for datetime types. r=smaug

parent e55dcb0d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -334,6 +334,12 @@ nsresult TimeInputType::GetRangeUnderflowMessage(nsAString& aMessage) {

// input type=week

nsresult WeekInputType::GetBadInputMessage(nsAString& aMessage) {
  return nsContentUtils::GetMaybeLocalizedString(
      nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidWeek",
      mInputElement->OwnerDoc(), aMessage);
}

bool WeekInputType::ConvertStringToNumber(nsAString& aValue,
                                          Decimal& aResultValue) const {
  uint32_t year, week;
@@ -397,6 +403,12 @@ bool WeekInputType::ConvertNumberToString(Decimal aValue,

// input type=month

nsresult MonthInputType::GetBadInputMessage(nsAString& aMessage) {
  return nsContentUtils::GetMaybeLocalizedString(
      nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidMonth",
      mInputElement->OwnerDoc(), aMessage);
}

bool MonthInputType::ConvertStringToNumber(nsAString& aValue,
                                           Decimal& aResultValue) const {
  uint32_t year, month;
@@ -446,6 +458,12 @@ bool MonthInputType::ConvertNumberToString(Decimal aValue,

// input type=datetime-local

nsresult DateTimeLocalInputType::GetBadInputMessage(nsAString& aMessage) {
  return nsContentUtils::GetMaybeLocalizedString(
      nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidDateTime",
      mInputElement->OwnerDoc(), aMessage);
}

bool DateTimeLocalInputType::ConvertStringToNumber(
    nsAString& aValue, Decimal& aResultValue) const {
  uint32_t year, month, day, timeInMs;
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ class DateTimeInputTypeBase : public InputType {

  bool IsMutable() const override;

  nsresult GetBadInputMessage(nsAString& aMessage) override = 0;

  /**
   * This method converts aValue (milliseconds within a day) to hours, minutes,
   * seconds and milliseconds.
@@ -106,6 +108,7 @@ class WeekInputType : public DateTimeInputTypeBase {
    return new (aMemory) WeekInputType(aInputElement);
  }

  nsresult GetBadInputMessage(nsAString& aMessage) override;
  bool ConvertStringToNumber(nsAString& aValue,
                             Decimal& aResultValue) const override;
  bool ConvertNumberToString(Decimal aValue,
@@ -123,6 +126,7 @@ class MonthInputType : public DateTimeInputTypeBase {
    return new (aMemory) MonthInputType(aInputElement);
  }

  nsresult GetBadInputMessage(nsAString& aMessage) override;
  bool ConvertStringToNumber(nsAString& aValue,
                             Decimal& aResultValue) const override;
  bool ConvertNumberToString(Decimal aValue,
@@ -140,6 +144,7 @@ class DateTimeLocalInputType : public DateTimeInputTypeBase {
    return new (aMemory) DateTimeLocalInputType(aInputElement);
  }

  nsresult GetBadInputMessage(nsAString& aMessage) override;
  bool ConvertStringToNumber(nsAString& aValue,
                             Decimal& aResultValue) const override;
  bool ConvertNumberToString(Decimal aValue,
+3 −0
Original line number Diff line number Diff line
@@ -38,6 +38,9 @@ FormValidationInvalidEmail=Please enter an email address.
FormValidationInvalidURL=Please enter a URL.
FormValidationInvalidDate=Please enter a valid date.
FormValidationInvalidTime=Please enter a valid time.
FormValidationInvalidDateTime=Please enter valid date and time.
FormValidationInvalidDateMonth=Please enter a valid month.
FormValidationInvalidDateWeek=Please enter a valid week.
FormValidationPatternMismatch=Please match the requested format.
# LOCALIZATION NOTE (FormValidationPatternMismatchWithTitle): %S is the (possibly truncated) title attribute value.
FormValidationPatternMismatchWithTitle=Please match the requested format: %S.