|
Wt
4.15.0
|
A validator for dateTime input. More...
#include <Wt/WDateTimeValidator.h>
Public Member Functions | |
| WDateTimeValidator () | |
| Creates a datetime validator. | |
| WDateTimeValidator (const WDateTime &bottom, const WDateTime &top) | |
| Creates a datetime validator. | |
| WDateTimeValidator (const WString &format) | |
| Creates a datetime validator. | |
| WDateTimeValidator (const WString &format, const WDateTime &bottom, const WDateTime &top) | |
| Creates a datetime validator. | |
| void | setBottom (const WDateTime &bottom) |
| Sets the bottom of the valid datetime range. | |
| const WDateTime & | bottom () const |
| Returns the bottom datetime of the valid range. | |
| void | setTop (const WDateTime &top) |
| Sets the top of the valid datetime range. | |
| const WDateTime & | top () const |
| Returns the top datetime of the valid range. | |
| void | setFormat (const WString &format) |
| Sets the datetime format used to parse datetime strings. | |
| WString | format () const override |
| Returns the format string used to parse datetime strings. | |
| void | setFormats (const std::vector< WString > &formats) |
| Sets the datetime formats used to parse datetime strings. | |
| const std::vector< WString > & | formats () const |
| Returns the datetime formats used to parse datetime strings. | |
| Result | validate (const WString &input) const override |
| Validates the given input. | |
| std::string | javaScriptValidate () const override |
| Creates a Javascript object that validates the input. | |
| void | setInvalidNotADateTimeText (const WString &text) |
| Sets the message to display when the input is not a datetime. | |
| WString | invalidNotADateTimeText () const |
| Returns the message displayed when the input is not a datetime. | |
| void | setInvalidTooEarlyText (const WString &text) |
| Sets the message to display when the datetime is earlier than bottom(). | |
| WString | invalidTooEarlyText () const |
| Returns the message displayed when datetime is too early. | |
| void | setInvalidTooLateText (const WString &text) |
| Sets the message to display when the datetime is later than top(). | |
| WString | invalidTooLateText () const |
| Returns the message displayed when the datetime is too late. | |
| Public Member Functions inherited from Wt::WValidator | |
| WValidator (bool mandatory=false) | |
| Creates a new validator. | |
| virtual | ~WValidator () |
| Destructor. | |
| void | setMandatory (bool how) |
| Sets if input is mandatory. | |
| bool | isMandatory () const |
| Returns if input is mandatory. | |
| void | setInvalidBlankText (const WString &text) |
| Sets the message to display when a mandatory field is left blank. | |
| WString | invalidBlankText () const |
| Returns the message displayed when a mandatory field is left blank. | |
| virtual std::string | inputFilter () const |
| Returns a regular expression that filters input. | |
Additional Inherited Members | |
| Public Types inherited from Wt::WValidator | |
| typedef ValidationState | State |
| Typedef for enum Wt::ValidationState. | |
A validator for dateTime input.
This validator accepts input in the given dateTime format, and optionally checks if the dateTime is within a given range.
The format string used for validating user input are the same as those used by WDateTime::fromString().
| Wt::WDateTimeValidator::WDateTimeValidator | ( | ) |
Creates a datetime validator.
The validator will accept datetimes using the current locale's format.
Creates a datetime validator.
The validator will accept only datetimes within the indicated range bottom to top.
| Wt::WDateTimeValidator::WDateTimeValidator | ( | const WString & | format | ) |
Creates a datetime validator.
The validator will accept dates in the date format format.
The syntax for format is as in WDateTime::fromString()
| Wt::WDateTimeValidator::WDateTimeValidator | ( | const WString & | format, |
| const WDateTime & | bottom, | ||
| const WDateTime & | top ) |
Creates a datetime validator.
The validator will accept only datetimes within the indicated range bottom to top, in the datetime format format.
The syntax for format is as in WDateTime::fromString()
|
overridevirtual |
Returns the format string used to parse datetime strings.
If multiple formats are specified, the first format in the list is returned.
Reimplemented from Wt::WValidator.
| WString Wt::WDateTimeValidator::invalidNotADateTimeText | ( | ) | const |
Returns the message displayed when the input is not a datetime.
| WString Wt::WDateTimeValidator::invalidTooEarlyText | ( | ) | const |
Returns the message displayed when datetime is too early.
| WString Wt::WDateTimeValidator::invalidTooLateText | ( | ) | const |
Returns the message displayed when the datetime is too late.
|
overridevirtual |
Creates a Javascript object that validates the input.
The JavaScript expression should evaluate to an object which contains a validate(text) function, which returns an object that contains the following two fields:
message that indicates the problem if not valid.Returns an empty string if the validator does not provide a client-side validation implementationq.
Reimplemented from Wt::WValidator.
| void Wt::WDateTimeValidator::setBottom | ( | const WDateTime & | bottom | ) |
Sets the bottom of the valid datetime range.
The default is an empty datetime constructed using WDateTime().
| void Wt::WDateTimeValidator::setFormat | ( | const WString & | format | ) |
Sets the datetime format used to parse datetime strings.
| void Wt::WDateTimeValidator::setFormats | ( | const std::vector< WString > & | formats | ) |
Sets the datetime formats used to parse datetime strings.
When multiple formats are given, the first format that correctly parses the input is used.
| void Wt::WDateTimeValidator::setInvalidNotADateTimeText | ( | const WString & | text | ) |
Sets the message to display when the input is not a datetime.
The default message is "The date and time must match the format {1}", with the format string as the first argument.
| void Wt::WDateTimeValidator::setInvalidTooEarlyText | ( | const WString & | text | ) |
Sets the message to display when the datetime is earlier than bottom().
Depending on whether bottom() and top() are defined (see WDateTime::isNull()), the default message is "The date and time must be between {1} and {2}" or "The date and time must be after {1}".
| void Wt::WDateTimeValidator::setInvalidTooLateText | ( | const WString & | text | ) |
| void Wt::WDateTimeValidator::setTop | ( | const WDateTime & | top | ) |
Sets the top of the valid datetime range.
The default is an empty datetime constructed using WDateTime::WDateTime().
|
overridevirtual |
Validates the given input.
The input is considered valid only when it is blank for a non-mandatory field, or represents a datetime in the given format, and within the valid range.
Reimplemented from Wt::WValidator.