Developing ASP.NET MVC Web Applications — Question 106
You need to enable client-side validation for an ASP.NET MVC application.
Which three actions should you perform? Each correct answer presents part of the solution.
Answer options
- A. Attach a custom validation attribute to the model properties that the view uses.
- B. Reference the jquery, jquery.validate and jquery.validate.unobtrusive script files in the view.
- C. Open the web.config file at the project root, and set the values of the ClientValidationEnabled and UnobtrusiveJavaScriptEnabled keys to True.
- D. For each form element, use the Validator.element() method to validate each item.
- E. Add data annotations to the model properties that the view uses.
Correct answer: B, C, E
Explanation
The correct answer includes referencing the necessary jQuery scripts, enabling client-side validation in the web.config, and adding data annotations for validation. Options A and D, while related to validation, do not specifically pertain to enabling client-side validation in this context.