[jQuery] Re: (validation) Validation plugin submitHandler
Also, that doesn't explain why the form still submits when I call form.submit(). Since submit is no longer a function, the form should never get submitted in that case. On Nov 12, 2:05 pm, Jörn Zaefferer wrote: > Use a different name for the submit-button. Using name="submit" you override > the actual submit-function of the form. Keep in mind that in the DOM API, > you can access any form element as a property of the form, referenced by > name. > > Jörn > > On Thu, Nov 12, 2009 at 8:48 PM, mcrawford wrote: > > I'm totally stumped with the submitHandler. Here is my test page, down > > below. I'm using PHP just to print out the form variables but > > obviously you could adapt the HTML for anything. > > > Notice that I have set my Submit button to have name="submit" which > > means that, in the submitHandler, form.submit() is not a function. I > > get a JavaScript error on that line, but (and this is what I can't > > figure out), the form still submits. > > > I can change the Submit button to have a different name, like > > name="sbmt". That avoids the JS error on the form.submit() line. But > > then (and I don't get this either), if you click the Cancel button, > > that value of cancel=Cancel will not get sent in the post. With the > > Submit button named "submit" the cancel=Cancel gets posted correctly > > when you click on that button. > > > > if (!empty($_POST)) { > > print_r($_POST); > > } > > ?> > > > http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> > > > > TEST > > > > > src="/js/jquery-1.3.2.js"> > > > > > > > > > id="the-form"> > > > value="something"/> > > > value="Do it > > now!"/> > > > name="cancel" > > value="Cancel"/> > > > > > > $(function() { > > // VALIDATION > > $("#the-form").validate({ > > submitHandler: function(form) { > > $('input[name=submit]', > > '#the-form').attr('disabled', > > 'disabled'); > > form.submit(); > > } > > }); > > }); > > > > > > > >
[jQuery] Re: (validation) Validation plugin submitHandler
Right, thanks. I mentioned that in my initial post. But if I rename the submit-button, if you click the Cancel button, that value of cancel=Cancel will not get sent in the post. Any ideas why? On Nov 12, 2:05 pm, Jörn Zaefferer wrote: > Use a different name for the submit-button. Using name="submit" you override > the actual submit-function of the form. Keep in mind that in the DOM API, > you can access any form element as a property of the form, referenced by > name. > > Jörn > > On Thu, Nov 12, 2009 at 8:48 PM, mcrawford wrote: > > I'm totally stumped with the submitHandler. Here is my test page, down > > below. I'm using PHP just to print out the form variables but > > obviously you could adapt the HTML for anything. > > > Notice that I have set my Submit button to have name="submit" which > > means that, in the submitHandler, form.submit() is not a function. I > > get a JavaScript error on that line, but (and this is what I can't > > figure out), the form still submits. > > > I can change the Submit button to have a different name, like > > name="sbmt". That avoids the JS error on the form.submit() line. But > > then (and I don't get this either), if you click the Cancel button, > > that value of cancel=Cancel will not get sent in the post. With the > > Submit button named "submit" the cancel=Cancel gets posted correctly > > when you click on that button. > > > > if (!empty($_POST)) { > > print_r($_POST); > > } > > ?> > > > http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> > > > > TEST > > > > > src="/js/jquery-1.3.2.js"> > > > > > > > > > id="the-form"> > > > value="something"/> > > > value="Do it > > now!"/> > > > name="cancel" > > value="Cancel"/> > > > > > > $(function() { > > // VALIDATION > > $("#the-form").validate({ > > submitHandler: function(form) { > > $('input[name=submit]', > > '#the-form').attr('disabled', > > 'disabled'); > > form.submit(); > > } > > }); > > }); > > > > > > > >