> I'm trying to use the beforeSubmit callback of the jQuery form plugin > to check some values with the server before submitting the entire > form, which can include a large file upload (which would be annoying > to upload, and then fail due to other submitted values being invalid-- > hence the pre-submit check). > > For reference:http://malsup.com/jquery/form/#code-samples > > The problem I'm having with running an Ajax request within > beforeSubmit, for example, is that it returns immediately (normally a > good thing). But beforeSubmit needs to wait for the value before > knowing whether it can return true or false. > > Anyone run into this before? I guess, in a nutshell, what I'm trying > to do is validate part of the form data by submitting it to a > different URL, then, depending on the response, submitting (or not > submitting) the entire form to the primary URL. > > ...Rene
You can accomplish this by always returning false from beforeSubmit. Then when you get the response from your validate ajax call you can submit the form manually. You may want to check out the validation plugin though, it lets you define validation rules up front and processes them for you. Mike