I've done something similar to this, where validation is may be run at
either field level or on form submit, or both (default is both, can be
overridden by invocation setting, below).

http://beta.ksscholl.com/jquery/formvalidate.html

Routine is invoked by the following snippet in the HEAD of the
document:

$("#myFormSample").jqValidate({
  // validateAt : "both", // "blur" | "submit" | "both"
  passMin : 6
  });

The validation script itself is the bottom half of the following:

http://beta.ksscholl.com/jquery/js/jqforms.js

and checks that required fields have data, as well as various
specialized fields have proper formatting and such.  I'm quite sure
that it could be cleaned up considerably by anyone more versed than
myself in the intricacies of jQuery, but I'm pretty pleased thus far.

Kevin


On Oct 13, 10:45 am, Nishan Karassik <[EMAIL PROTECTED]> wrote:
> Wouldn't the $("#my-form [EMAIL PROTECTED]'input']").blur(function() { be
> my trigger?
>
> I would like to validate as the user tabs through the form.  How would
> I not run the function if the field just tabbed from is blank?
>
> Thanks for your validation of my script.
>
> Nishan
>
> On Oct 13, 7:30 am, "Jörn Zaefferer" <[EMAIL PROTECTED]>
> wrote:
>
> > Validation should always hook into the submit event, eg.
> > $(#myform").submit(function() { ... });
> > That handles both clicking the submit button as well as hitting enter
> > while an input field has focus.
>
> > Apart from that, the form plugin handles submitting forms via ajax and
> > handling the response quite well, including file 
> > uploads:http://malsup.com/jquery/form/
>
> > Jörn
>
> > On Mon, Oct 13, 2008 at 5:57 AM, Nishan Karassik <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
>
> > > I have never written a Jquery script, but have, over the last few
> > > days, compiled the following, but was hoping someone could look over
> > > this to see if I had problems.
>
> > > $(document).ready(function () {
> > >        $("#my-form [EMAIL PROTECTED]'input']").blur(function() {
> > >                var queryString = $.("#my-form").formSerialize();
> > >                $.post("/path/to/your/validation.php", queryString,
> > > function(validation_errors) {
> > >                        // do something like changing a css class, disable 
> > > submit...
> > >                        $.each(validation_errors, function(err_id, 
> > > err_message) {
> > >                        $(err_id).val() = err_message;
> > >                        }
> > >                )};
> > >        });
> > > )});
>
> > > Thanks,
> > > Nishan

Reply via email to