You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Usage example not working: using validator directly with a group of inputs Created May 5, 2010

This thread is solved

Views: 3729     Replies: 5     Last reply Dec 1, 2011  
You must login first before you can use this feature

mjj

Posts: 5

Registered:
May 5, 2010

Usage example not working: using validator directly with a group of inputs

Posted: May 5, 2010

The validator usage example says that it is possible to validate inputs without a form by passing in the inputs:

Validating inputs without a form

The tool validates all input fields except buttons and hidden fields inside a particular form. You can also select particular fields and validate them. For example:

// initialize validator for a bunch of input fields
var inputs = $("#mydiv :input").validator();

// perform validation programmatically
inputs.data("validator").checkValidity();

However, when I try this, my firebug displays the following:

uncaught exception: Validator: no input fields supplied

Is there wrong something with the example, or am I doing something wrong?

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» Usage example not working: using validator directly with a group of inputs

Posted: May 6, 2010

Reply to: Usage example not working: using validator directly with a group of inputs, from matthewj
you've found a bug. will be fixed for 1.2.1 to be released within a week or two.

THANKS!

mjj

Posts: 5

Registered:
May 5, 2010

» » Usage example not working: using validator directly with a group of inputs

Posted: May 6, 2010

Reply to: » Usage example not working: using validator directly with a group of inputs, from tipiirai
Thanks for the ultra-fast response!

To give a little more background, what I was attempting to do was replace the per-pane validation in your scrollable registration wizard demo with the validator tool, rather than the basic "required fields only" validation your demo supports. To that end, I was trying to do a per-wizard pane validation using the validator on all inputs in the div. This appears to be the suggested approach in the scrollable wizard demo:

If you want to implement a proper validation logic please use the Validator Tool.

I assume I'm using the tool as recommended, but just have to wait for this bug fix.

One of my goals with this was to implement the bubble-style error messages as shown in this example. I'm no jQuery expert, and I'm not sure of a clean, quick way to implement that using the current wizard approach without the validator tool. The magic the validator is doing is in:

$("#myform").validator({ 
	position: 'top left', 
	offset: [-12, 0],
	message: '<div><em/></div>' // em element is the arrow
});

I suppose the best solution for me in the meantime while I wait for 1.2.1 to be released is to keep the basic validations as is until I can do a per-div validation, and live with the drawer slide down approach. Or I could attempt to add this div myself on a per-element basis, though it wouldn't likely be as clean as the validator approach.

There's no other real workarounds where I can make use of the validator tool to validate part of the form at a time in the meantime, correct?

Thanks again!

EDIT: Added mention of bubble-style error messages