struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Madel,Kurt" <kma...@csmi.com>
Subject RE: Struts Validator for multiple Selects
Date Tue, 29 Oct 2002 14:01:56 GMT
OK, for anyone that needs to require multi-selects, adding the following to
the require function seems to work (could anyone answer why this isn't
already included?):

form[oRequired[x][0]].type == 'select-multiple'

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

function validateRequired(form) {


                var bValid = true;

                var focusField = null;

                var i = 0;


                var fields = new Array();


                oRequired = new required();


 


                for (x in oRequired) {


                    if ((form[oRequired[x][0]].type == 'text' ||
form[oRequired[x][0]].type == 'textarea' || form[oRequired[x][0]].type ==
'select-one' || form[oRequired[x][0]].type == 'radio' ||
form[oRequired[x][0]].type == 'password' || form[oRequired[x][0]].type ==
'select-multiple') && form[oRequired[x][0]].value == '') {

Kurt Madel
Programmer, CSMi
(703) 823-4300 ext. 170


-----Original Message-----
From: Madel,Kurt 
Sent: Tuesday, October 29, 2002 7:51 AM
To: 'Struts Users Mailing List'
Subject: RE: Struts Validator for multiple Selects

Anyone use multi-selects with Struts Validation?

Oh yeah, the jsp is:

<html:javascript formName="milestoneDetailForm" dynamicJavascript="true"/>
<html:form action="/addmilestone" onsubmit="return
validateMilestoneDetailForm(this);">
 	<table  class="form">
	<html:hidden property="mrevdate"/>
	<tr>
	<td align="left" valign="center">
		<FONT class="label"><B>Milestone Description:</B></FONT>
	</td>
	<td align="left" valign="center">
		<html:textarea property="description" rows="3"
cols="80"/><html:errors property="description" />
	</td>
	</tr>		
	<tr>
	<td align="left" valign="center">
		<FONT class="label"><B>DOE Manager(s):</B></FONT>
	</td>
	<td align="left" valign="center">
	<html:select property="mspersonsIds" size="4" multiple="true">
		<html:options collection="managerList" property="id"
labelProperty="name" />
	</html:select><html:errors property="mspersonsIds" />
	</td>
	</tr>			
	</table>
	
    <html:link href="#" onclick="javascript:if
(document.forms[0].onsubmit())document.forms[0].submit()">
      	Add
    </html:link>    
</html:form>

Kurt Madel
Programmer, CSMi
(703) 823-4300 ext. 170


-----Original Message-----
From: Madel,Kurt [mailto:kmadel@csmi.com] 
Sent: Monday, October 28, 2002 4:24 PM
To: 'Struts Users Mailing List'
Subject: Struts Validator for multiple Selects

We have a multiple select that is required. The following works on server
side, but not client side:

<form name="milestoneDetailForm">
		<field 
			property="mspersonsIds[0]"
    		depends="required">
     	    <arg0 key="label.milestone.mspersonsIds"/>    	   
    	</field> 
   	</form>

If changed to the following, it is caught on the server side, but no message
is printed:
<form name="milestoneDetailForm">
		<field 
			property="mspersonsIds"
    		depends="required">
     	    <arg0 key="label.milestone.mspersonsIds"/>    	   
    	</field> 
   	</form>

Any ideas? Thanks

Kurt Madel
Programmer, CSMi
(703) 823-4300 ext. 170


--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message