[jQuery] Re: Validate 1.2 Questions
jason schrieb: Thanks guys, I'm starting to get a handle on it now. This is an incredible piece of work, Jörn! You're welcome to post what you come up with, I may add that as examples for custom methods to the documentation, and maybe as the first FAQ entry. Jörn
[jQuery] Re: Validate 1.2 Questions
Thanks guys, I'm starting to get a handle on it now. This is an incredible piece of work, Jörn! - jason On Jan 31, 7:28 pm, Jörn Zaefferer <[EMAIL PROTECTED]> wrote: > Priest, James (NIH/NIEHS) [C] schrieb: > > > [...] > >> (2) How do you indicate dependencies within the markup, as opposed to > >> within the plugin call? In other words, if I have a group of radio > >> buttons, and a text input that is only required if a certain radio > >> button is checked, can I add something to the markup of the text input > >> to indicate that? > > > I haven't done that but I think you could use the visible example like > > I've shown above to do something similar: > > > elementwhichischecked: {required: "#parentelement:checked"} > > > Or something along those lines... > > I recommend using custom methods to encapsulate the logic for such > dependency checks, that way you'll just have to use that method in the > markup and no code at all. > > Jörn
[jQuery] Re: Validate 1.2 Questions
Priest, James (NIH/NIEHS) [C] schrieb: [...] (2) How do you indicate dependencies within the markup, as opposed to within the plugin call? In other words, if I have a group of radio buttons, and a text input that is only required if a certain radio button is checked, can I add something to the markup of the text input to indicate that? I haven't done that but I think you could use the visible example like I've shown above to do something similar: elementwhichischecked: {required: "#parentelement:checked"} Or something along those lines... I recommend using custom methods to encapsulate the logic for such dependency checks, that way you'll just have to use that method in the markup and no code at all. Jörn
[jQuery] Re: Validate 1.2 Questions
> -Original Message- > From: jason [mailto:[EMAIL PROTECTED] > (1) How do you control where the error label appears for grouped > elements like radio buttons and checkboxes? Right now it's appearing > right after the first one for me. See 'errorPlacement' - example code below - this checks to see if I have a div or span after my label - if so it places the error AFTER those elements. If not it defaults to inserting it right after the label. $("#frmtelework").validate({ errorPlacement: function(label, element) { if ( element.next("div").length ) { label.insertAfter( element.next() ); } else if ( element.next("span").length ) { label.insertAfter( element.next() ); } else { label.insertAfter( element ); } $(label).wrap(''); }, rules: { // to make hidden elements required do: // elementwhichishidden: {required: "#parentelement:visible"}, personIDdisplay:{required: true}, homeaddress1: {required: true}, homecity: .. > > (2) How do you indicate dependencies within the markup, as opposed to > within the plugin call? In other words, if I have a group of radio > buttons, and a text input that is only required if a certain radio > button is checked, can I add something to the markup of the text input > to indicate that? I haven't done that but I think you could use the visible example like I've shown above to do something similar: elementwhichischecked: {required: "#parentelement:checked"} Or something along those lines... Jim