This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1.1 - validations - requiredif is not working

 
chingh tangh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts 1.1, wrote the following for "requiredif" validation, but it doesn't work:
here is validations.xml
<field property="age" depends="required">
<arg0 key="label.age"/>
</field>
<field property="name" depends="requiredif">
<arg0 key="label.name"/>
<var>
<var-name>field[0]</var-name>
<var-value>age</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>NOTNULL</var-value>
</var>
</field>
[ I have tried for NOTNULL and also NULL]
I have defined in the form beans as
===================================
<form-bean name="TestForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="age" type="java.lang.String" />
<form-property name="name" type="java.lang.String" />
<form-property name="testSubmit" type="java.lang.String" />
</form-bean>

My jsp is here:
==============
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:form action="someAction" onsubmit="return validateTestForm(this)" >
<html:text property="age" value="" />
<html:text property="name" value="" />
<html:submit property="testSubmit" value="TSubmit" />
</html:form>
<html:javascript formName="TestForm"/>
Here required validation for age is working, But name is not being validated for "requiredif".
I have seen the html page generated, it doesn't have the javascript code for name.
Only requiredif is not working...
what may be the problem...???
Pls clarify.
Thanks in advance.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic