Hi,

 

I have some problems validating multiple radio buttons and checkboxes,
selections on the client side. Tracking down to the javascript code
defined in validator-rules.xml, I found that the validateRequired(form)
function doesn't deal with multiple checkboxes, selections at all. For
multiples radios, checkboxes etc, the field.type = undefined. Can
somebody explain why is this?

 

Thanks,

Saul

 

 

Validator-rules.xml:

-----------------------------------------------------------------

 

            function validateRequired(form) {

                var isValid = true;

                var focusField = null;

                var i = 0;

                var fields = new Array();

                oRequired = new required();

                for (x in oRequired) {

                        var field = form[oRequired[x][0]];

                        

                    if (field.type == 'text' ||

                        field.type == 'textarea' ||

                        field.type == 'file' ||

                        field.type == 'select-one' ||

                        field.type == 'radio' ||

                        field.type == 'password') {

                        

                        var value = '';

 
// get field's value

 
if (field.type == "select-one") {

 
var si = field.selectedIndex;

 
if (si >= 0) {

 
value = field.options[si].value;

 
}

 
} else {

 
value = field.value;

 
}

                        

                        if (trim(value).length == 0) {

                        

                                    if (i == 0) {

                                        focusField = field;

                                    }

                                    fields[i++] = oRequired[x][1];

                                    isValid = false;

                        }

                    }

                }

                if (fields.length > 0) {

                   focusField.focus();

                   alert(fields.join('\n'));

                }

                return isValid;

            }

Reply via email to