I tried building a testcase and it appeared that the problem was not
id-with-dash related, it's the radio buttons validation that simply
wasn't working at all !

There's a demo of radio buttons validating at
http://jquery.bassistance.de/validate/demo/radio-checkbox-select-demo.html
but it is using the validate="required:true" attribute to do so, and
this breaks the w3c validation of the code...

I've eventually found by trial and error that it is working if I use
the name attribute instead of the id attribute in the rules :
rules: {
        genre: {
                required: true
        }
}

Now I just have to sort out the place where the error message is
displayed and that'll be fine.
I hope this can help others when they encounter that same problem...


On 14 sep, 13:31, mattso <matthieu.larc...@gmail.com> wrote:
> I've tried using the quotes on names that don't have a dash in it and
> this works, but it won't work with the ones that do contain a dash (-)
> (they are radio buttons)
> Is this really supposed to work ?
>
> Any clue would be appreciated
>
> On 11 sep, 16:03, mattso <matthieu.larc...@gmail.com> wrote:
>
> > Thanks for your reply, Jörn.
>
> > I've tried :
>
> > rules: {
> >         "genre-f": "genreCheck",
> >         "genre-m": "genreCheck"
>
> > }
>
> > and :
>
> > rules: {
> >         "genre-f": {
> >                 genreCheck: true
> >         },
> >         "genre-m": {
> >                 genreCheck: true
> >         }
>
> > }
>
> > with :
>
> > $.validator.addMethod('genreCheck', function (value) {
> >         alert('called');
> >         if( $("#genre-f").is(":checked") || $("#genre-m").is(":checked") ){
> >                 return true;
> >         }else{
> >                 return false;
> >         }
>
> > }, "Please select a genre.");
>
> > but I don't get any error message and the alert in the genreCheck
> > function shows it's not even called.
> > Any idea why ?
>
> > On 11 sep, 15:40, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
> > wrote:
>
> > > Seehttp://docs.jquery.com/Plugins/Validation/Reference#Fields_with_compl...
>
> > > Jörn
>
> > > On Fri, Sep 11, 2009 at 2:26 PM, mattso <matthieu.larc...@gmail.com> 
> > > wrote:
>
> > > > Hi,
>
> > > > I'm using the bassistance.de Validation Plugin for jQuery and I have
> > > > the following problem :
>
> > > > When using a dash(-) separated id for genres (i.e. genre-f / genre-m),
> > > > I get the following js error : "missing : after property id" with the
> > > > following code:
> > > > rules: {
> > > >        genre-f: {
> > > >                required: "#genre-m"
> > > >        },
> > > >        genre-m: {
> > > >                required: function() {
> > > >                        return $("#genre-f").is(":checked");
> > > >                }
> > > >        },
> > > > It seems that the js (json?) doesn't allow the use of a - inside a
> > > > variable name.
>
> > > > Unfortunately, I can't change the id names, as they are being
> > > > generated by Zend Framework which doesn't allow to replace it with
> > > > another character.
>
> > > > Anybody would know a way around this ?
>
> > > > It seems to me that in the case of multi-options inputs, the script
> > > > should focus on the name instead of the id...
> > > > Any clue would be appreciated.

Reply via email to