Its in the validate documentation
http://docs.jquery.com/Plugins/Validation/Methods/required#dependency-expression

In your case

rules: {
         newColor: {
             required:  function(element) {
                        return $("#color").val() == -1;
                        }
       }



On Jun 24, 10:52 pm, ciupaz <luigi.zambe...@gmail.com> wrote:
> Hi all,
> I have to validate a textbox if the user select a particular value in
> a combobox.
> For example, if the user select the "Specify new color" in the
> following combobox:
>
> <select id="color" name="color">
>        <option value="-1">Specify new color</option>
>        <option value="1">Red</option>
>        <option value="2">Green</option>
>        <option value="3">Blue</option>
>        <option value="4">White</option>
>        <option value="5">Black</option>
> </select>
>
> I have to validate the following textbox:
>
> <input id="newColor" name="newColor" type="text" />
>
> with the Validate Plugin:
>
> rules: {
>          newColor: {
>              required: ??????
>        },
>
> How can I accomplish this?
>
> Thanks in advance.
>
> Luis.

Reply via email to