Wt
4.11.0
|
A validator for validating floating point user input. More...
#include <Wt/WDoubleValidator.h>
Public Member Functions | |
WDoubleValidator () | |
Creates a new double validator that accepts any double. | |
WDoubleValidator (double minimum, double maximum) | |
Creates a new double validator that accepts double within the given range. | |
double | bottom () const |
Returns the bottom of the valid double range. | |
void | setBottom (double bottom) |
Sets the bottom of the valid double range. | |
double | top () const |
Returns the top of the valid double range. | |
void | setTop (double top) |
Sets the top of the valid double range. | |
virtual void | setRange (double bottom, double top) |
Sets the range of valid doubles. | |
virtual Result | validate (const WString &input) const override |
Validates the given input. | |
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. | |
void | setIgnoreTrailingSpaces (bool b) |
If true the validator will ignore trailing spaces. | |
bool | ignoreTrailingSpaces () |
Indicates whether the validator should ignore the trailing spaces. | |
virtual std::string | javaScriptValidate () const override |
Creates a Javascript object that validates the input. | |
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 WString | format () const |
Returns the validator format. | |
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 validating floating point user input.
This validator checks whether user input is a double in the 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.WDoubleValidator.NotANumber: Must be a number Wt.WDoubleValidator.TooSmall: The number must be larger than {1} Wt.WDoubleValidator.BadRange: The number must be in the range {1} to {2} Wt.WDoubleValidator.TooLarge: The number must be smaller than {1}
Wt::WDoubleValidator::WDoubleValidator | ( | ) |
Creates a new double validator that accepts any double.
The validator will accept numbers using the current locale's format.
Creates a new double validator that accepts double within the given range.
The validator will accept numbers using the current locale's format.
bool Wt::WDoubleValidator::ignoreTrailingSpaces | ( | ) |
Indicates whether the validator should ignore the trailing spaces.
WString Wt::WDoubleValidator::invalidNotANumberText | ( | ) | const |
Returns the message displayed when the input is not a number.
WString Wt::WDoubleValidator::invalidTooLargeText | ( | ) | const |
Returns the message displayed when the number is too large.
WString Wt::WDoubleValidator::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.
Sets the bottom of the valid double range.
The default value is the minimum double value.
If true the validator will ignore trailing spaces.
Sets the message to display when the input is not a number.
The default value is "Must be a number."
Sets the top of the valid double range.
The default value is the maximum double value.
|
overridevirtual |
Validates 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.