rleland 2003/07/29 20:30:12 Modified: conf/share validator-rules.xml Log: Bug 21751 report and patch provided by Kurt Post Allow intRange validation of select-one and radio fields. In Kurt's words: In some form combo boxes you might have the combo boxes populated with valid choices plus one additional choice with a caption something like "Choose one" and a value 0f "-1". Then when the user attempts to submit the form, you can look for the value of "-1" and yell at them if they failed to pick something. Revision Changes Path 1.35 +13 -6 jakarta-struts/conf/share/validator-rules.xml Index: validator-rules.xml =================================================================== RCS file: /home/cvs/jakarta-struts/conf/share/validator-rules.xml,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- validator-rules.xml 1 Jul 2003 17:52:09 -0000 1.34 +++ validator-rules.xml 30 Jul 2003 03:30:12 -0000 1.35 @@ -806,14 +806,21 @@ oRange = new intRange(); for (x in oRange) { var field = form[oRange[x][0]]; - - if ((field.type == 'text' || - field.type == 'textarea') && - (field.value.length > 0)) { - + var value = ''; + if (field.type == 'text' || field.type == 'textarea' || + field.type == 'radio' ) { + value = field.value; + } + if (field.type == 'select-one') { + var si = field.selectedIndex; + if (si >= 0) { + value = field.options[si].value; + } + } + if (value.length > 0) { var iMin = parseInt(oRange[x][2]("min")); var iMax = parseInt(oRange[x][2]("max")); - var iValue = parseInt(field.value); + var iValue = parseInt(value); if (!(iValue >= iMin && iValue <= iMax)) { if (i == 0) { focusField = field;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]