1

I have a HTML form with several inputs. The required fields are controlled by one combobox in the form. That means that the required fields are dynamically assigned according to the combo.

Now I am controlling this behaviour in code, the validation function check if all the required fields (according to the property of the combo) are filled, otherway the required fields are shown in red.

For me this approach has two disadvantadges:

  1. There is an overload on the server, checking, on any change of the form, if the required fields are filled or not.
  2. I have no way to generate a view to define the required fields by the user. Everything is in source code.

I have been thinking how to store this info in the DB to solve both problems, but all the solution force me to store names of properties/fields on the DB that maybe could change on the future. And it is not clear how to propagate this info into the ViewModels.

Do you have any suggestions? How do you solve this recurrent problem?

Thanks in advance.

The application is developed on ASP .NET MVC

amalbala
  • 118
  • 1
  • 12
  • 2
    As a comment, point 1 shouldn't be considered as a disadvantage. It's better to do both validations: client-side AND server-side. Client-side validation gives you fast response and doesn't charge the server. Server-side validation protects you against malicious users: http://stackoverflow.com/questions/162159/javascript-client-side-vs-server-side-validation – Rumpelstinsk Aug 17 '16 at 07:10
  • Agree. And I am not planning on removing the server validation because the objects could come from oher sources than the Web UI. But I would prefer to check on the server only on submit (or sent) and not on every change of the form to update the UI info. – amalbala Aug 17 '16 at 07:49

0 Answers0