Hi. I'm trying to make a script which submits the form without refreshing the page. Also, I'd like to have it submit onkeyup.
I can't figure out how to do that.

Can anyone help me?

My code is

<script type="text/javascript">
    	var $form = $( '#myform' ),
        url = $form.attr( 'action' );

			submitHandler: function(form) {
				var rData = $("#myform").serialize();
				$.post(url, rData, function(data) {


Edited by calebcook: n/a

6 Years
Discussion Span
Last Post by bloodbender

No. I can submit/display if I click on the submit button (or hit enter), but if I use onkeyup="document.myform.submit();" it submits the form and reloads the page.


I'm not familiar with the validate plugin. But, maybe, instead of using onkeyup="document.myform.submit();" you can use something like this:

			if ( evt.keyCode == 13 ) // Enter

Hope it helps.


Hmm. Doesn't work. (and I dont want the user to have to hit anything. I want it to automatically submit when they've typed something.)


If you do the normal submit, the page will reload. What you need is Ajax part to do the submission for you, so that your page will not reload but only a portion of what you want will be reloaded.

I'm not familiar with JQuery to use Ajax. You may need to search for JQuery and Ajax to answer your question. I can do it in pure JavaScript though.

PS: If you are going to use Ajax, you need a server to return the request.

Edited by Taywin: n/a


Try this:

    // Do validation here
    // If validation passes, submit

although that won't give your use m

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.