A validator is a rule set that validates user input, and can be
associated with any WFormWidget.
Validation takes place both at the client side (in the browser)
and server side. The advantage of client-side validation is that
the user receives feedback without a server round-trip time, but
this requires JavaScript support, and this can also easily be
tampered with or circumvented. Therefore, server-side validation
is always required in any case. All built-in validators provide
both client-side and server-side validation. If you implement a
custom validator, client-side validation (in JavaScript) may be
optional. You could consider to reimplement
WRegExpValidator, as it is quite flexible and will give
you client-side validation out-of-the-box.
Wt supplies validators for dates, doubles, integers, string
length (minimum and maximum) and regular expressions. You can
also implement your own server-side/client-side validators.
The example below uses a red background to indicate invalid
fields, the default in Wt.