Wt
4.11.1
|
A validator that validates integer user input. More...
#include <Wt/WIntValidator.h>
Public Member Functions | |
WIntValidator () | |
Creates a new integer validator that accepts any integer. More... | |
WIntValidator (int minimum, int maximum) | |
Creates a new integer validator that accepts integer input within the given range. More... | |
int | bottom () const |
Returns the bottom of the valid integer range. | |
void | setBottom (int bottom) |
Sets the bottom of the valid integer range. More... | |
int | top () const |
Returns the top of the valid integer range. | |
void | setTop (int top) |
Sets the top of the valid integer range. More... | |
virtual void | setRange (int bottom, int top) |
Sets the range of valid integers. | |
virtual Result | validate (const WString &input) const override |
Validates the given input. More... | |
void | setInvalidNotANumberText (const WString &text) |
Sets the message to display when the input is not a number. More... | |
WString | invalidNotANumberText () const |
Returns the message displayed when the input is not a number. More... | |
void | setInvalidTooSmallText (const WString &text) |
Sets the message to display when the number is too small. More... | |
WString | invalidTooSmallText () const |
Returns the message displayed when the number is too small. More... | |
void | setInvalidTooLargeText (const WString &text) |
Sets the message to display when the number is too large. More... | |
WString | invalidTooLargeText () const |
Returns the message displayed when the number is too large. More... | |
void | setIgnoreTrailingSpaces (bool b) |
If true the validator will ignore trailing spaces. More... | |
bool | ignoreTrailingSpaces () |
Indicates whether the validator should ignore the trailing spaces. More... | |
virtual std::string | javaScriptValidate () const override |
Creates a Javascript object that validates the input. More... | |
virtual std::string | inputFilter () const override |
Returns a regular expression that filters input. More... | |
Public Member Functions inherited from Wt::WValidator | |
WValidator (bool mandatory=false) | |
Creates a new validator. More... | |
virtual | ~WValidator () |
Destructor. More... | |
void | setMandatory (bool how) |
Sets if input is mandatory. More... | |
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. More... | |
WString | invalidBlankText () const |
Returns the message displayed when a mandatory field is left blank. More... | |
virtual WString | format () const |
Returns the validator format. More... | |
Additional Inherited Members | |
Public Types inherited from Wt::WValidator | |
typedef ValidationState | State |
Typedef for enum Wt::ValidationState. | |
A validator that validates integer user input.
This validator checks whether user input is an integer number in a pre-defined range.
Usage example:
The strings used in this class can be translated by overriding the default values for the following localization keys:
Wt::WIntValidator::WIntValidator | ( | ) |
Creates a new integer validator that accepts any integer.
The validator will accept numbers using the current locale's format.
Wt::WIntValidator::WIntValidator | ( | int | minimum, |
int | maximum | ||
) |
Creates a new integer validator that accepts integer input within the given range.
bool Wt::WIntValidator::ignoreTrailingSpaces | ( | ) |
Indicates whether the validator should ignore the trailing spaces.
|
overridevirtual |
Returns a regular expression that filters input.
The returned regular expression is used to filter keys presses. The regular expression should accept valid single characters.
For details on valid regular expressions, see WRegExpValidator. As an example, "[0-9]" would only accept numbers as valid input.
The default implementation returns an empty string, which does not filter any input.
Reimplemented from Wt::WValidator.
WString Wt::WIntValidator::invalidNotANumberText | ( | ) | const |
Returns the message displayed when the input is not a number.
WString Wt::WIntValidator::invalidTooLargeText | ( | ) | const |
Returns the message displayed when the number is too large.
WString Wt::WIntValidator::invalidTooSmallText | ( | ) | const |
Returns the message displayed when the number is too small.
|
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::WIntValidator::setBottom | ( | int | bottom | ) |
Sets the bottom of the valid integer range.
The default value is the minimum integer value.
void Wt::WIntValidator::setIgnoreTrailingSpaces | ( | bool | b | ) |
If true the validator will ignore trailing spaces.
void Wt::WIntValidator::setInvalidNotANumberText | ( | const WString & | text | ) |
Sets the message to display when the input is not a number.
The default value is "Must be an integer number."
void Wt::WIntValidator::setInvalidTooLargeText | ( | const WString & | text | ) |
void Wt::WIntValidator::setInvalidTooSmallText | ( | const WString & | text | ) |
void Wt::WIntValidator::setTop | ( | int | top | ) |
Sets the top of the valid integer range.
The default value is the maximum integer value.
|
overridevirtual |
Validates the given input.
The input is considered valid only when it is blank for a non-mandatory field, or represents an integer within the valid range.
Reimplemented from Wt::WValidator.