Gareth,

>I thought I'd try the $.ajax method as suggested and after much mucking
>about it seems to be working :) The only thing that doesn't work is the
>timeout which is (very) bad because, as you pointed out, if the validation
>page doesn't respond / takes too long the browser locks. Under the
>circumstances (single app on a dedicated server) I'm prepared to take the
>risk. Obviously, if someone can tell me why the timeout doesn't work here
>I'd love to know.

Here's another idea, and one I'll be demoing tomorrow at Spring<br />
Conference in Athens, OH.

The basic idea is use the Form Validation Plug-in to validate what you can,
and then use the Form Plug-in to submit the form via AJAX. 

Since you should always be implementing Server-side validation (never rely
strictly on client-side validation--it's too easy to bypass,) validate the
form as you normally would, and build any errors into an array of
structures--which includes the field identifier and message.

Then you pass back to the form a JSON packet that looks something like:

{
        success: false,
        errors: {
                username: "Please try a different user name.",
                zipcode:  "You entered an invalid zip code."
        }
}

Once the AJAX operation completes, you'll know whether the form was
successfully submitted via the success status and you can pass in the the
errors key directly into the showErrors() function in the Form Validation
library to display any errors the server caught.
 
As soon as I finalize my presentation, I plan on blogging all the source
files and presentation to my blog at http://blog.pengoworks.com/.

You might want to keep an eye out for my post.

-Dan


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to