Yes Yuan, It is working for all other function even password comparision also. I need one more help for fixing password size I used minimum length but it is not working, may not supporting '*" char. What need to be done for the same?
-Jignesh On Monday 15 March 2004 06:43, Saul Q Yuan wrote: > If you havn't done so, I'd suggest you view souce and see if you have the > correct javascript code rendered in you jsp. If you set > staticJavascript="true" in your <html:javascript ... tag, then the > javascript should be rendered inside your jsp. You can even put in some > alert box in your validator-rules.xml file to see if the required method > actually gets called. BTW, do you have javascript validation working for > other type of form fields? > > > Saul > > ----- Original Message ----- > From: Jignesh Patel > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED] ; [EMAIL PROTECTED] ; > [EMAIL PROTECTED] ; [EMAIL PROTECTED] ; [EMAIL PROTECTED] Sent: Sunday, > March 14, 2004 9:43 AM > Subject: urgent:multibox client side validation > > > Dear Friends, > > I have implemented multibox, everything is working fine. > But I would like to validate the checkboxes, my purpose is atleast one > checkbox will be selected from the user while submitting, if not message > will be pop up. > > I am implementing javascript(client side) validation, > > > > My validation.xml contains following code > > <field property="selectedMagazines" depends="required"> > <arg0 key="interestsForm.selectedMagazines"/> > </field> > > I have tried the code, which is posted by "Yuan" as follows in > validator-rule.xml, but it didn't worked out. > > > 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' || // -- true for single > radio button, Saul Q Yuan ([EMAIL PROTECTED]) 10/28/03 > field.type == 'checkbox' || // -- true for > single checkbox, Saul Q Yuan ([EMAIL PROTECTED]) 10/28/03 > 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; > } > // -- get value for > checked single radio button or checkbox, Saul Q Yuan > ([EMAIL PROTECTED]) 10/28/03 > } else if (field.type == > "radio" || field.type == "checkbox") { > if > (field.checked) { > value = > field.value; > } > } else { > value = field.value; > } > > if (trim(value).length == 0) { > > if (i == 0) { > focusField = field; > } > fields[i++] = oRequired[x][1]; > isValid = false; > } > } else if (field.type == "select-multiple") { > var numOptions = field.options.length; > lastSelected=-1; > for(loop=numOptions-1;loop>=0;loop--) { > if(field.options[loop].selected) { > lastSelected = loop; > value = field.options[loop].value; > break; > } > } > if(lastSelected < 0 || trim(value).length == 0) > { > if(i == 0) { > focusField = field; > } > fields[i++] = oRequired[x][1]; > isValid=false; > } > } else if ((field.length > 0) && (field[0].type == > 'radio' || field[0].type == 'checkbox')) { > isChecked=-1; > for (loop=0;loop < field.length;loop++) { > if (field[loop].checked) { > isChecked=loop; > break; // only one needs to be checked > } > } > if (isChecked < 0) { > if (i == 0) { > focusField = field[0]; > } > fields[i++] = oRequired[x][1]; > isValid=false; > } > } > } > if (fields.length > 0) { > focusField.focus(); > alert(fields.join('\n')); > } > return isValid; > } > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]