Hello Leonardo and all,

Ok, that's well!
And if I need to bind a click event to the group of radiobuttons, how
can I do that?
If I write something like this:

$("#utype1").click (function (event) {
if ($(this).is(":checked")) $("#showann").hide(); else $("#showann").show();
});

the #showann div will be processed only when clicking the first radio
button. How do I process them all?

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

----- Original message -----
From: Leonardo K <leo...@gmail.com>
To: jquery-en@googlegroups.com <jquery-en@googlegroups.com>
Date: Tuesday, December 15, 2009, 3:58:52 PM
Subject: [jQuery] Validation plugin: required by condition

Something like this:

<input type="radio" name="blog-entry" value="personal-entry"/>
<input type="radio" name="blog-entry" value="publication"/>
<input type="radio" name="blog-entry" value="post"/>

<textarea name="announce"></textarea>

$(form).validate({
    rules:{
        announce: {
            required: function(element) {
                var value = $("input[name='blog-entry']").val();
                if ( val == 'publication' || val == 'post' ){
                    return true;
                }else{
                    return false;
                }
            }
        }
    }
});

On Tue, Dec 15, 2009 at 11:24, Andre Polykanine <an...@oire.org> wrote:

> Hello everyone,
>
> I have a text field (textarea) that is required only if a specific
> radio button in the group is checked.
> Here's the explanation: a blog entry may be a personal entry, a
> publication and a news post. If it's a news post or a
> publication, then the
> announce is required.
> How can I manage that with the plugin? what rule do I use?
> Thanks!
>
> --
> With best regards from Ukraine,
> Andre
> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> Twitter: m_elensule
>
>

Reply via email to