2

I want to submit a form like this:

<input type="button" onclick="$('#form1').submit();" value="Create" />

but the ASP.NET MVC 2 Model Validation doesn't work.

4
  • In which way does it not work? Have you tried using AJAX instead? What exactly do you try to accomplish with the line above? jQuery's .submit() will NOT submit the form data. Also, you should register a callback to see the result. What version of jQuery are you using? Commented Mar 6, 2010 at 8:16
  • Client or server side validation doesn't work? Commented Mar 6, 2010 at 8:19
  • Perhaps you could explain why you are using jQuery for this at all? Why don't you use a simple submit button? You can still register callbacks using ajaxForm. Commented Mar 6, 2010 at 9:33
  • The client validation doesn't work. My page is a little complex, contains several forms. And our client demand the submit button should place at the bottom of page. So I have to do like before, a submit button outside it's form. Commented Mar 6, 2010 at 10:03

1 Answer 1

1

You could try simulating a click on the actual submit button:

<input type="button" onclick="$('#form1 input:submit').click();" value="Create" />
Sign up to request clarification or add additional context in comments.

2 Comments

This way is good! Thanks! But I have to put a hidden submit button in my form. I wait to see if there is a better way.
It is semantically more correct to submit forms with submit or image buttons.

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.