Kostas
Kostas

Reputation: 2474

Custom non-attribute based form validation in ASP.NET MVC 4 framework

Is there a way to define a non-attribute based form validation?

There used to be an asp:CustomValidator in ASP.NET WebForms which lets validating form element using custom programmer-defined function in code-behind page. Is it possible to do something similar in MVC framework?

Upvotes: 0

Views: 179

Answers (2)

Kostas
Kostas

Reputation: 2474

As AliRıza Adıyahşi I will create an ActionFilter attribute on my controller action. Just putting it here so the question is no longer unanswered.

Upvotes: 0

Kim R
Kim R

Reputation: 561

Try this article:

http://msdn.microsoft.com/en-us/library/gg508808(v=vs.98).aspx

This still uses attributes but only to specify the action of your custom validation code.

You can always use the onchange event of your forms input elements to trigger AJAX calls if you really need to.

Upvotes: 1

Related Questions