rickharrison / validate.js

Lightweight JavaScript form validation library inspired by CodeIgniter.
http://rickharrison.github.io/validate.js
Other
2.56k stars 406 forks source link

Validation issue with radio buttons and fieldset in Safari #110

Open pixelatorz opened 10 years ago

pixelatorz commented 10 years ago

Hi

I was struggling to get the validation working for my radio button group. After a while I noticed the fieldset around the radio buttons (with the same ID as the name attribute of the radio buttons) caused the issue. Below is the link to a jsfiddle. When you submit the form without selecting a radio button the validation passes on Safari (Chrome works as expected).

When removing or changing the id from "opt" to something else in the jsfiddle, the validation works as expected resulting in a 'invalid' alert box.

Do you have any idea what could be causing this behaviour?

http://jsfiddle.net/Zrg4q/3/

rickharrison commented 10 years ago

Safari gets confused with having the same name, and it is reporting the incorrect value. For now, you should try and use a separate id for the fieldset. I will work on a solution, but it may require a little bit of a refactor.

pixelatorz commented 10 years ago

yes, I fixed it that way :) Just wanted to let you know this strange behaviour in Safari.