User Input Validation

Pages written using the Razor syntax can take advantage of both client-side and server-side validation. This validation is actually provided by the jQuery.validate.js plug-in (script files) included with the default project template. Recall that the model already includes field-level validation rules using data annotations. These rules will be applied to the client code by ASP.NET when binding the model fields to the view. Of course, these same rules will process on the server, too.

The HTML helper methods and TagHelpers can be used to define validation; they require the jquery.validate plug-in to be added to the view. Recall that the shared _Layout.cshmtl page defined a section called scripts for adding script files to ...

Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.