FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Radio Button Group Validation Not Working
#1
Hi,

I have the following JS validation rules setup -

Code:
var rules = [];
rules.push("required,Recruitment_Source,Please select a Recruitment Source.");
rules.push("required,Name_First,Please enter your first name.");
rules.push("required,Name_Last,Please enter your last name.");
rules.push("required,email,Please enter your email address.");
rules.push("valid_email,email,Please enter a valid email address.");

The first rule for field named "Recruitment_Source" is a set of radio buttons. If I leave them all unselected, and leave the other required fields blank and submit the form, the browser jumps to the radio buttons as though it is about to alert that the field is required, but instead it continues to the thank you page.

If I remove the radio button group from the rules, validation works fine on all of the other text input fields. Having the validation on the radio buttons basically breaks all validation.

Seems like a bug. Any ideas?

Thanks in advance,
Ryan
Reply
#2
Hi Ryan,

Yeah, that does sound rather like a bug - but I'd be rather surprised, because I've used it to validation radio button groups countless times. So maybe it's an incompatibility with a newer browser? It sounds like it's focusing on the field then throwing some sort of error - or not returning false (just to check, your onsubmit handler is like this, correct? onsubmit="return rsv.validate(this, rules)" ).

Would you mind trying it on a different browser to see if it still occurs? If it occurs on another browser as well than it's a bug. Otherwise, it's more likely an idiosyncracy of your form.

Do you have a link to the page?

- Ben
Reply
#3
Hi Ben,

My form tag looks like this -
Code:
<form action="/form-new.php" method="POST" onsubmit="return rsv.validate(this, rules)">

Also it does occur in various browsers.

I'll PM a link to the form.

Thanks!
Ryan
Reply
#4
Hi Ryan,

Thanks for sending me a link to the form - it took a little puzzling though, but I found out the problem.

It's actually not so much a problem with the RSV library as the modification I tell you to make in the documentation, to make it compatible with the modifications I made to the RSV script bundled in the core.

To fix it, change this line:
Code:
rsv.errorFieldClass = null;

to this:
Code:
rsv.errorFieldClass = "";

That should make all errors mysteriously vanish...! Smile

Sorry for the headache. I'll have to update the documentation.

- Ben
Reply
#5
Thumbs Up 
Good find! Thanks for the fix! Smile
Reply
#6
These rules are easy to understand and the input method is so convenient, thanks to you in advance. My further interest is the can we implement this routine at https://www.topbritishwriters.com/uk-writing-experts-review/ for further development of code and secure login of the users?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)