Priest, James (NIH/NIEHS) [C] schrieb:
-----Original Message-----
From: Jörn Zaefferer [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 26, 2008 2:33 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: [validate] need help with addMethod


Priest, James (NIH/NIEHS) [C] schrieb:
Jörn, the issue is it's not a checkbox :) It's a set of
radio buttons:  o yes o no
The user must select 'yes' or they can't continue to submit
the form.
Okay, if you want to stick with radio buttons for a boolean value, please post a testpage with what you've got so far.

Yes - unfortunately it's a client decision to do the 'yes/no' ... AND it is an 
intranet page so I have no code to show :(

But here is the HTML:

I have read these terms and conditions and agree to all of the provisions 
contained above.
<input name="terms" id="termsy" value="Yes" type="radio"><label 
for="termsy">Yes</label>
<input name="terms" id="termsn" value="No" type="radio"><label 
for="termsn">No</label>

Then for my validation:

$.validator.addMethod("checkyesno", function(value) {
        if (value == 'Yes') {
                return true;
        } else {
                return false;
        }
},
"You must read and agree to the terms and conditions before
proceeding.");

My rules:
rules: {
        terms: {required: true, checkyesno: true}
},

Seems simple but I can't seem to make it work!
It could be related to a different issue that I solved recently. Could you give the latest revision a try? http://dev.jquery.com/view/trunk/plugins/validate/

Jörn

Reply via email to