By default, MVC form fields have both client-side and server-side validation. You can, however, customize the default validation behavior by editing the settings and properties for each field. For example, you can customize the default maximum length value of the text box field that enforces limitations of the text the user enters.
You customize the client-side validation via the HTML5 built-in validation attributes. On the other hand, you customize the server-side validation via the business logic in the field model. You basically override and change the default validation models.
PREREQUISITES: You first need to register a custom module. For more information, see For developers: Install a module with the Fluent API.
In the following example, you override the default validation of the Paragraph text field. You override the client-side validation by changing the ValidationAttributes property value in the following manner:
The code above, you make every Paragraph text field a required field. Note that this change only affects the client-side validation.
To change the server-side validation logic, you override the IsValid method in the following manner:
Thus, every server-side validation of this field is forced to return true. Depending on your requirements, you can add your own custom logic of validating the field.
Back To Top
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.