[jQuery] [validate]
[jQuery] [validate]
I'm using jquery validate plugin and I have a problem with rules
depending of form selectors.
In my form I have got two form selectors:
<select name="client.clientType" id="type" class="iefixmargin"><option
value="">-- Wybierz --</option>
<option value="B">Bezrobotny</option>
<option value="N">Nieaktywny zawodowo</option>
<option value="Z">Zatrudniony</option>
<option value="I">Inny</option>
<option value="P">Przedsiebiorstwo</option>
<option value="S">Samozatrudnony</option></select>
and
<input name="clientnip" id="clientnip" maxlength="14" value=""
class="tekst" type="text">
I'd like to make "clientnip" required if "type" value is "P" or "S".
I tried this:
$("#clientnip").rules("add", {
required: function(element) {
return $("#type").val() == "P";
return $("#type").val() == "S";
}
It works for type value = "P" and ignore "S".
Could some one help me?