0

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?

2
  • 1
    You can write your own filter attribute. This is the similar logic. Commented Feb 7, 2013 at 10:07
  • Forgot I can do that. Thanks! Commented Feb 7, 2013 at 10:15

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Didn't know about remote validation, but it still relies on attributes being placed on model properties. I will do as AliRıza Adıyahşi suggested, that gives me full control and doesn't rely on attributes :)
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.