Public Member Functions | |
WDateValidator (WObject *parent=0) | |
Construct a date validator. | |
WDateValidator (const WDate &bottom, const WDate &top, WObject *parent=0) | |
Construct a date validator. | |
WDateValidator (const WString &format, WObject *parent=0) | |
Construct a date validator. | |
WDateValidator (const WString &format, const WDate &bottom, const WDate &top, WObject *parent=0) | |
Construct a date validator. | |
void | setBottom (const WDate &bottom) |
Set the bottom of the valid date range. | |
const WDate & | bottom () const |
Get the bottom date of the valid range. | |
void | setTop (const WDate &top) |
Set the top of the valid date range. | |
const WDate & | top () const |
Get the top date of the valid range. | |
void | setFormat (const WString &format) |
Set the date format used to parse date strings. | |
const WString & | format () const |
Get the format string used to parse date strings. | |
virtual State | validate (WString &input, int &pos) const |
Validate the given input. | |
virtual void | createExtConfig (std::ostream &config) const |
Provide Ext-compatible config options for client-side validation. | |
void | setInvalidNotADateText (const WString &text) |
Set the message to display when the input is not a date. | |
WString | invalidNotADateText () const |
Returns the message displayed when the input is not a date. | |
void | setInvalidTooEarlyText (const WString &text) |
Set message to display when the date is earlier than bottom. | |
WString | invalidTooEarlyText () const |
Returns the message displayed when date is too early. | |
void | setInvalidTooLateText (const WString &text) |
Set message to display when the date is later than top. | |
WString | invalidTooLateText () const |
Returns the message displayed when the date is too late. | |
Static Public Member Functions | |
static WDate | parse (const WString &input) |
Parse a date from a string. | |
Protected Member Functions | |
std::string | javaScriptValidate (const std::string &jsRef) const |
Creates a Javascript expression that validates the input. |
This validator accepts input in the given date format, and optionally checks if the date is within a given range.
The format string used for validating user input are the same as those used by WDate::fromString(const WString&, const WString&).
Wt::WDateValidator::WDateValidator | ( | WObject * | parent = 0 |
) |
Construct a date validator.
The validator will accept any date of the format 'yyyy-MM-dd'.
Wt::WDateValidator::WDateValidator | ( | const WDate & | bottom, | |
const WDate & | top, | |||
WObject * | parent = 0 | |||
) |
Construct a date validator.
The validator will accept dates in the indicated range in the format 'yyyy-MM-dd'.
Construct a date validator.
The validator will accept dates in the date format format.
The syntax for format is as in WDate::fromString(const WString&, const WString&)
Wt::WDateValidator::WDateValidator | ( | const WString & | format, | |
const WDate & | bottom, | |||
const WDate & | top, | |||
WObject * | parent = 0 | |||
) |
Construct a date validator.
The validator will accept only dates within the indicated range bottom to top, in the date format format.
The syntax for format is as in WDate::fromString(const WString&, const WString&)
void Wt::WDateValidator::setBottom | ( | const WDate & | bottom | ) |
Set the bottom of the valid date range.
The default is a null date constructed using WDate().
void Wt::WDateValidator::setTop | ( | const WDate & | top | ) |
Set the top of the valid date range.
The default is a null date constructed using WDate().
void Wt::WDateValidator::setFormat | ( | const WString & | format | ) |
Set the date format used to parse date strings.
const WString& Wt::WDateValidator::format | ( | ) | const [inline] |
WValidator::State Wt::WDateValidator::validate | ( | WString & | input, | |
int & | pos | |||
) | const [virtual] |
Validate the given input.
The input is considered valid only when it is blank for a non-mandatory field, or represents a date in the given format, and within the valid range.
Reimplemented from Wt::WValidator.
Parse a date from a string.
Equivalent to WDate::fromString(input, "yyyy-MM-dd");
void Wt::WDateValidator::setInvalidNotADateText | ( | const WString & | text | ) |
Set the message to display when the input is not a date.
The default message is "The date must be of the format {1}", with as first argument the format string.
WString Wt::WDateValidator::invalidNotADateText | ( | ) | const |
Returns the message displayed when the input is not a date.
void Wt::WDateValidator::setInvalidTooEarlyText | ( | const WString & | text | ) |
WString Wt::WDateValidator::invalidTooEarlyText | ( | ) | const |
Returns the message displayed when date is too early.
void Wt::WDateValidator::setInvalidTooLateText | ( | const WString & | text | ) |
WString Wt::WDateValidator::invalidTooLateText | ( | ) | const |
Returns the message displayed when the date is too late.
std::string Wt::WDateValidator::javaScriptValidate | ( | const std::string & | jsRef | ) | const [protected, virtual] |
Creates a Javascript expression that validates the input.
The JavaScript expression should evaluate to an object with two fields: a boolean valid, and a message that indicates the problem if not valid.
Return an empty string if you are not provide the client-side validation.
Reimplemented from Wt::WValidator.