1

I am having troubles making my own form with validation in ASP.NET MVC. I want to make the form entirely using html and javascript but every example that I find on the internet won't work when put into a view on my asp.net mvc site.

I have this jsFiddle: http://jsfiddle.net/epic720/V3p9f/

That works just fine until I paste it into a page on my mvc site. The inputs get a red border around them but the error message labels do not get created.

I have set ClientValidationEnabled and UnobtrusiveJavaScriptEnabled to false in the web.config.

EDIT: I replaced my copy of jquery in the project with the latest version of jquery and now I am no longer having this issue.

3
  • Why don't you want to use Html.BeginForm? Commented Apr 21, 2012 at 19:24
  • I want to keep everything html and javascript based as I am unsure if my project will stay in ASP.NET MVC and I want it to be a portable interface. Commented Apr 21, 2012 at 19:36
  • So you're not really doing MVC then. See, MVC requires that you have an actual View, and if your "view" is just html that you populate via ajax only, then it's not a view. If you're not going to take advantage of what MVC gives you, and you can't if you wish to remain agnostic, then there's no point in using MVC at all. Just use something like WebAPI or RIA, or just plain old WebMethods. Commented Apr 21, 2012 at 20:04

2 Answers 2

1

For anyone interested in a combination of Data Attributes on model Validation and not using Html.BegionForm() you can try to add this

@{ ViewContext.FormContext = new FormContext(); }

before your <form> element

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

Comments

0

Not sure what the problem is but my solution would be to create an non razor or webform partial and render it inside your view.

1 Comment

I've done every combination of this and still can't get the error messages to appear. I have no idea what the problem is either.

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.