#include <Wt/WDoubleValidator>
Public Member Functions | |
WDoubleValidator (WObject *parent=0) | |
Create a new double validator that accepts any double. | |
WDoubleValidator (double minimum, double maximum, WObject *parent=0) | |
Create a new double validator that accepts double within the given range. | |
double | bottom () const |
Return the bottom of the valid double range. | |
void | setBottom (double bottom) |
Set the bottom of the valid double range. | |
double | top () const |
Return the top of the valid double range. | |
void | setTop (double top) |
Set the top of the valid double range. | |
virtual void | setRange (double bottom, double top) |
Set the range of valid doubles. | |
virtual State | validate (WString &input) const |
Validate the given input. | |
virtual void | createExtConfig (std::ostream &config) const |
Provide Ext-compatible config options for client-side validation. | |
void | setInvalidNotANumberText (const WString &text) |
Set 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) |
Set 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) |
Set 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. |
This validator checks whether user input is a double in the pre-defined range.
Usage example:
Wt::WLineEdit *lineEdit = new Wt::WLineEdit(this); Wt::WDoubleValidator *validator = new Wt::WDoubleValidator(); lineEdit->setValidator(validator); lineEdit->setText("13.42");
double Wt::WDoubleValidator::bottom | ( | ) | const [inline] |
Return the bottom of the valid double range.
The default value is -stdnumeric_limits<int>::max().
void Wt::WDoubleValidator::setTop | ( | double | top | ) |
Set the top of the valid double range.
The default value is std::numeric_limits<int>::max().
WValidator::State Wt::WDoubleValidator::validate | ( | WString & | input | ) | const [virtual] |
Validate the given input.
The input is considered valid only when it is blank for a non-mandatory field, or represents a double within the valid range.
Reimplemented from Wt::WValidator.
void Wt::WDoubleValidator::setInvalidNotANumberText | ( | const WString & | text | ) |
Set the message to display when the input is not a number.
The default value is "Must be a number."
WString Wt::WDoubleValidator::invalidNotANumberText | ( | ) | const |
Returns the message displayed when the input is not a number.
void Wt::WDoubleValidator::setInvalidTooSmallText | ( | const WString & | text | ) |
WString Wt::WDoubleValidator::invalidTooSmallText | ( | ) | const |
Returns the message displayed when the number is too small.
void Wt::WDoubleValidator::setInvalidTooLargeText | ( | const WString & | text | ) |
WString Wt::WDoubleValidator::invalidTooLargeText | ( | ) | const |
Returns the message displayed when the number is too large.
std::string Wt::WDoubleValidator::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.