Unfortunately i am using Struts 1.1 and commons-validator 1.0 On 2/10/06, Vladislav Pernin <[EMAIL PROTECTED]> wrote:
> Which version of commons-validator are you using. > > I'm using Struts 1.2.8 and commons-validator 1.2.0, it validate only the > non disabled field. > > ------------------------ > Extracted from commons-validator.jar : > function validateRequired(form) { > var isValid = true; > var focusField = null; > var i = 0; > var fields = new Array(); > > oRequired = eval('new ' + retrieveFormName(form) + '_required()'); > > for (x in oRequired) { > var field = form[oRequired[x][0]]; > > if (field == null) { > fields[i++] = oRequired[x][1]; > isValid=false; > } else if ((field.type == 'hidden' || > field.type == 'text' || > field.type == 'textarea' || > field.type == 'file' || > field.type == 'radio' || > field.type == 'checkbox' || > field.type == 'select-one' || > field.type == 'password') && > *field.disabled == false*) { > ------------------------ > > > Vlad > Madhav Bhargava wrote: > > >Hi All, > > > >I have a JSP page where on the select of a radio button some controls are > >disabled/enabled. The form bean associated with this JSP extends > >ValidatorForm. I have created rules in validation-xml for each of these > >controls which are there on the screen. One rule that is common to all > the > >controls is -"required". > > > >Depending on the selection of the radio button different methods in a > >DispatchAction class are called. If i need to do server side validations > >then how can i prevent the validator framework to validate controls which > >have been disabled. > > > >For client side validations i can just do some slight modifications in > >validation-rules.xml and get the behavior i want. > > > >For server side validations of this kind i can think of the following: > >1. Override the apache class that provides the "required" behavior, then > >change validator-rules.xml to have the custom class instead. > >2. override the validate method in the form bean and based on the request > >attributes get only errors for the controls that are enabled. - Somehow > this > >method though simple fix does not appeal to me much. > > > >What can be the best way in which this can be acheived. > > > >One more thing: > > > >Does struts provide you a way in which you can check in a form bean > whether > >a control was disabled. The behavior that i observed is that if the > control > >is disabled then the value in the form bean is null. Which is also the > case > >when the user does not enter anything in the control. > > > >Regards, > >madhav > > > > > > > >-- > >When I tell the truth, it is not for the sake of convincing those who do > not > >know it, but for the sake of defending those that do > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- When I tell the truth, it is not for the sake of convincing those who do not know it, but for the sake of defending those that do