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
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important
Copyright © 2023 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.
Powered by Progress Sitefinity