Thank you for all of your help to date Joel. I still can't get this darn
thing working. The snippet you sent me runs without errors, but does not
alert when a group has been missed.

I have this, but it only works when the first radio button is selected. Any
other advice?

function CheckSurvey (formData, jqForm, options){
    //Check multiple choice questions
    for (var i=1; i <=7; i++) {
        if ( !$("#p"+i+"q1").is(":checked") ) { alert ( "Please answer
question #1 on page #"+i ); return false; }
        if ( !$("#p"+i+"q2").is(":checked") ) { alert ( "Please answer
question #2 on page #"+i ); return false; }
        if ( !$("#p"+i+"q3").is(":checked") ) { alert ( "Please answer
question #3 on page #"+i ); return false; }
    }
    //Check essay questions
    for (var i=0; i < formData.length; i++) {
        if (!formData[i].value) {
            alert('Please answer both of the essay questions on page 8');
            return false;- Hide quoted text -

        }
    }
}

On 9/5/07, Joel Birch <[EMAIL PROTECTED]> wrote:
>
>
> On 9/6/07, Joel Birch <[EMAIL PROTECTED]> wrote:
>
> > function validate_form(){
> >         var valid = true;
> >         //loop through the radio sets
> >         $('tr.radioSet').each(function(){
> >                 var theRadioSet = this;
> >                 //make sure at least one radio is checked
> >                 //do not use @ symbol if using jQuery 1.1.4, it's
> deprecated
> >                 if ( $('input[type=radio]:checked',theRadioSet).length
> != -1 ){
> >                         valid = false;
> >                         alert ('The question with id
> "'+theRadioSet.id+'" was not answered');
> >                         return false; //I *think* this halts further
> 'each' cycles
> >                 }
> >         });
> >         return valid;
> > }
>
> Sorry, already found an error. This line:
>
> if ( $('input[type=radio]:checked',theRadioSet).length != -1 ){
>
> Should be:
>
> if ( $('input[type=radio]:checked',theRadioSet).length == -1 ){
>
> ...it's very late...
>
> Joel.
>
> >
>


-- 
Shaun Kester
----------------------
[EMAIL PROTECTED]
http://www.skfox.com

Reply via email to