#include <Wt/WIntValidator>
Public Member Functions | |
WIntValidator (WObject *parent=0) | |
Creates a new integer validator that accepts any integer. | |
WIntValidator (int minimum, int maximum, WObject *parent=0) | |
Creates a new integer validator that accepts integer input within the given range. | |
int | bottom () const |
Returns the bottom of the valid integer range. | |
void | setBottom (int bottom) |
Sets the bottom of the valid integer range. | |
int | top () const |
Returns the top of the valid integer range. | |
void | setTop (int top) |
Sets the top of the valid integer range. | |
virtual void | setRange (int bottom, int top) |
Sets the range of valid integers. | |
virtual State | validate (WString &input) const |
Validates the given input. | |
virtual void | createExtConfig (std::ostream &config) const |
Provides Ext-compatible config options for client-side validation. | |
void | setInvalidNotANumberText (const WString &text) |
Sets the message to display when the input is not a number. | |
WString | invalidNotANumberText () const |
Returns the message displayed when the input is not a number. | |
void | setInvalidTooSmallText (const WString &text) |
Sets the message to display when the number is too small. | |
WString | invalidTooSmallText () const |
Returns the message displayed when the number is too small. | |
void | setInvalidTooLargeText (const WString &text) |
Sets the message to display when the number is too large. | |
WString | invalidTooLargeText () const |
Returns the message displayed when the number is too large. | |
Protected Member Functions | |
std::string | javaScriptValidate (const std::string &jsRef) const |
Creates a Javascript expression that validates the input. | |
std::string | inputFilter () const |
Returns a regular expression that filters input. |
This validator checks whether user input is an integer number in a pre-defined range.
Usage example:
Wt::WLineEdit *lineEdit = new Wt::WLineEdit(this); Wt::WIntValidator *validator = new Wt::WIntValidator(0, 100); lineEdit->setValidator(validator); lineEdit->setText("50");
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::setTop | ( | int | top | ) |
Sets the top of the valid integer range.
The default value is the maximum integer value.
WValidator::State Wt::WIntValidator::validate | ( | WString & | input | ) | const [virtual] |
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.
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."
WString Wt::WIntValidator::invalidNotANumberText | ( | ) | const |
Returns the message displayed when the input is not a number.
void Wt::WIntValidator::setInvalidTooSmallText | ( | const WString & | text | ) |
WString Wt::WIntValidator::invalidTooSmallText | ( | ) | const |
Returns the message displayed when the number is too small.
void Wt::WIntValidator::setInvalidTooLargeText | ( | const WString & | text | ) |
WString Wt::WIntValidator::invalidTooLargeText | ( | ) | const |
Returns the message displayed when the number is too large.
std::string Wt::WIntValidator::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.
std::string Wt::WIntValidator::inputFilter | ( | ) | const [protected, virtual] |
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.