Root's Validator property
The MForm Root control conforms to the ASP.NET validation scheme.
Instead of creating a separate validator control for the Root control,
the control provides itself a inner content property Validator
This Validator property is a RootValidator object that
inherits form the ASP.NET BaseValidator class.
Hence, all the properties available to standard .NET validators are also available
in the RootValidator. These are:
ValidationGroup - a named group of common validators
Text - a static text displayed on error
Display - a display type: None, Static or Dynamic
Except that, a Placement property is available - so that it can be specified where the error message should be displayed: before or after Root content.
If the error should be displayed somewhere else, the .NET ValidationSummary control may be used.
The validator in the Root control is created and enabled by default.
If you want to disable the validator functionality, set the Enabled
property to false.
The MForm inner validation process
The RootValidator control coordinates the validation of the controls
tree inside the Root control, both on the client and on the server
side.
Each of the MForm item controls may contain a Constraint object inside
the Additions property. The Constraint property must
implement the IsValid method, that takes the item as the parameter
- this way the validation is perforemed on server side. Each class inheriting form
the Constraint also adds a client script resource to the page. When
the MForm item is loaded on the client side, it has all the constraints registered
- and they are checked on item values change - this way the validation is performed
on the client side.
For existing MForm item constraints look in the Constraints chapter.
Every constraint has an ErrorText property.
This property is a description of the error in case of a situation when the constraint is not met.
When MForm is validated, it stops for the first constraint that is not matched. The displayed error text concerns the item that is the owner of the constraint.
By default, the error message will only be shown on button pressing and will display only the data about the errorneous field.
For a solution to add error messages near the fields, check the
Error label example page