0

Today I must validate my form, and I have problem.

I have 2 radio buttons: - Company id: #firma - Private person id: #osoba

If company is checked I must validate NIP (company number) input as required and PESEL (person number) as not required.

If private person is checked I must validate PESEL as required and NIP as not required.

PESEL id: #pesel NIP id: #nip

I tried:

$("#domainform").validate({
  rules: {
    nip: {
      required: "#firma:checked"
    },
    pesel: {
      required: "#osoba:checked"
    }
  }, 
  debug: true
});
Jonas
  • 121,568
  • 97
  • 310
  • 388
Mateusz Kudej
  • 447
  • 1
  • 8
  • 23
  • conditional validation might help: http://stackoverflow.com/questions/1084475/jquery-validate-conditional-validation-radiobutton-and-dropdownlist – Marcelo Diniz Jan 22 '12 at 17:55

1 Answers1

0

You code is just ok, check the demo.

xdazz
  • 158,678
  • 38
  • 247
  • 274