views:

137

answers:

2
<% Html.BeginForm("Index", "Home", FormMethod.Post, new { id = "form_logon" }); %>
or
<form id = "form_logon", action="/Home/Index" method="post">

just don't work. Pressing a submit button if ID is present does nothing, while id is required for jQuery validation plugin.

+1  A: 

Are you sure you don't have any javascript errors on your page? I use the first format pretty extensively with no problems, with and without the Validation plugin. Note that your second example has an extra comma, but I'm guessing that's a transcription error. I'd look to make sure that you don't have a javascript error that is halting all javascript on the page (though that wouldn't explain a plain, old submit button not working).

tvanfosson
Agreed. Look also for duplicate IDs. That's invalid HTML and breaks *lots* of things.
Craig Stuntz
Thanks for help. The comma is only a copy/paste error here.i've fixed a problem. Problem was in another script that deals with AJAX post form where IE returns error (null) while other browsers work fine.I had to rewrite the whole part and now it all works OK.If you're interested, the problem was with jQuery .ajax() function that breaks in IE8 (win7) on timeouts for onreadystatechange prop.For an unknown reason, my form wasn't fireing at all when I was using the code block that also did validation.Thank you anyway.
BuzzBubba
A: 

I got similar issue and couldn't get any proper solution to this. However, since I only had one form in my MVC page, I reverted back to Html.BeginForm() without any parameters, and in the jQuery code, I just used the following:

$("form").validate(/* my rules and messages */);

instead of:

$("#userForm").validate(/* my rules and messages */);

Hope this helps.

Regards Naweed

Naweed Akram