aspose file tools*
The moose likes Struts and the fly likes validation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validation error" Watch "validation error" New topic
Author

validation error

prem ranjith
Greenhorn

Joined: Jul 03, 2009
Posts: 13
Hellow Friends,


Now i am wrirtitng the coding validation for the form field. using struct frame work.. program will be run but canot validate the form fields....

my jsp page:
-------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="Bean" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration</title>
</head>
<body bgcolor="#C2DFFF">

<center>
<table width="300px;">
<tr>
<th>
<font face="Times New Roman">Employee Registration</font>
</th></tr>
</table>
</center>

<html:form method="post" action="reg" onsubmit="return validateRegstrationForm(this);">
<div style="width:800px; align="left">
<fieldset style="left:100px">
<legend>Employee Detatis</legend>
<table style="width:800px" border="0" >
<tr>
<td style="width:200px">Employee ID </td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:500px" ><html:text property="empid"></html:text></td>
<td style="width:150px">Department</td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:200px"><html:select property="dept">
<htmlption value="1">sales</htmlption>
<htmlption value="1"></htmlption>
<htmlption value="1"></htmlption>
</html:select></td>
</tr>
<tr>
<td style="width:150px">First Name</td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:500px"><html:text property="efname"></html:text> </td>
<td style="width:150px">Designation</td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:200px"><html:select property="desig">
<htmlption value="1">sales</htmlption>
<htmlption value="2"></htmlption>
<htmlption value="3"></htmlption>
</html:select> </td>
</tr>

<tr>
<td style="width:150px">Initial/Middle Name</td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:500px"><html:text property="emname"></html:text> </td>
</tr>
<tr>
<td style="width:150px">Last Name</td>
<td style="width:50px" align="left"><font color="red"></font></td>
<td style="width:500px"><html:text property="elname"></html:text> </td>
</tr>
</table>
</fieldset>
</div>
<!------------------------------- Personal Details ------------------------------- -->
<div style="width:800px;"align="left">
<fieldset style="left:100px">
<legend>Personal Detatis</legend>
Address
<table style="width:800px" border="0">
<tr>
<td style="width:150px">Door/Flat No</td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:500px" ><html:text property="doorno"></html:text> </td>
</tr>
<tr>
<td style="width:150px">Location </td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:500px"><html:text property="location"></html:text> </td>
</tr>
<tr>
<td style="width:150px">Area</td>
<td style="width:50px" align="left"><font color="red">*</font></td>
<td style="width:500px"><html:text property="area"></html:text> </td>
</tr>
<tr>
<td style="width:150px">District</td>
<td style="width:50px" align="left"><font color="red"></font></td>
<td style="width:500px"><html:select property="district">
<htmlption value="1">sales</htmlption>
</html:select>
</td>
</tr>
</table>
<!-- State -->
<table style="width:800px" border="0" >
<tr>
<td style="width:400px">State</td>
<td style="width:100px" align="left"><font color="red">*</font></td>
<td style="width:225px"><html:select property="stat">
<htmlption value="1">sales</htmlption>
<htmlption value="2"></htmlption>
<htmlption value="3"></htmlption>
</html:select> </td>

<td style="width:300px" align="right">Zip Code</td>
<td style="width:70px" ><font color="red">*</font></td>
<td style="width:520px" align="left"><html:text property="zipcode" size="6"></html:text> </td>
</tr>
</table>


<table border="0" style="width: 800px">
<tr>

<td style="width:164px">Country</td>
<td style="width:58px" align="left"><font color="red"> *</font></td>
<td style="width:572px"><html:text property="country" disabled="disabled"></html:text></td>
</tr>
<tr>
<td style="width:164px">Phone No</td>
<td style="width:58px" align="left"><font color="red"></font></td>
<td style="width:572px"><html:text property="stdcode" size="5"></html:text>-<html:text property="phno" size="8"></html:text> </td>

</tr>
<tr>
<td style="width:164px">Moblie No</td>
<td style="width:58px" align="left"><font color="red"> *</font></td>
<td style="width:572px"><html:text property="ccode" size="5"></html:text> -<html:text property="mobileno"></html:text> </td>

</tr>
<tr>
<td style="width:164px">Sex</td>
<td style="width:58px" align="left"><font color="red"> *</font></td>
<td style="width:572px"><html:radio property="sex" value="Male">Male</html:radio><html:radio property="sex" value="female">Female</html:radio> </td>
</tr>

<tr>
<td style="width:164px">Date Of Birth</td>
<td style="width:58px" align="left"><font color="red"> *</font></td>
<td style="width:572px"><html:select property="dd"><htmlption value="1"></htmlption>
<htmlption value="2"></htmlption>
</html:select>
<html:select property="mm"><htmlption value="1"></htmlption></html:select>
<html:select property="yyy"><htmlption value="2"></htmlption></html:select>
</td>

</tr>
<tr>
<td style="width:164px">E-Mail</td>
<td style="width:58px" align="left"><font color="red"> *</font></td>
<td style="width:572px"><html:text property="email" ></html:text> </td>
</tr>
<tr>
<td align="center" colspan="3"><html:submit value="Register"></html:submit> <html:submit value="Cancel" ></html:submit> </td>
</tr>
</table>

</fieldset>
</div>
</html:form>
<html:javascript formName="RegstrationForm"/>
</body>
</html>


my web.xml file
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Sample</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResource</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/struts-layout.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-layout.tld</taglib-location>
</taglib>
</web-app>

my strut-config file
---------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources>
</data-sources>
<!-- form-beans Starts Here -->
<form-beans>
<form-bean name="RegBean" type="com.Bean.RegBean"/>
</form-beans>


<action-mappings>
<action path="/reg" name="RegBean" type="com.Action.RegAction ">
<forward name="s" path="/Home.jsp"/>
</action>
<action path="/in" name="RegBean" type="com.Action.InsetReg">
<forward name="ok" path="/Home.jsp"/>
</action>
</action-mappings>


<message-resources parameter="com.Action.ApplicationResource" />
<!-- Validator plug in -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>


my validation.xml
--------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">

<form-validation>

<!--
This is a minimal Validator form file with a couple of examples.
-->

<global>
<!-- global constant for name format -->
<constant>
<constant-name>payScale</constant-name>
<constant-value>^[0-9][0-9-]*[0-9]+$</constant-value>
</constant>
<constant>
<constant-name>remarks</constant-name>
<constant-value>^[^']*$</constant-value>
</constant>
<constant>
<constant-name>orderFooters</constant-name>
<!-- <constant-value>^[^'][^$]*$</constant-value> -->
<constant-value>^[^$]*$</constant-value>
</constant>
<constant>
<constant-name>pincodeMask</constant-name>
<constant-value>^[0-9][0-9 ]*$</constant-value>
</constant>
<constant>
<constant-name>phoneMask</constant-name>
<constant-value>^\d{2,3}-\d{3,4}-\d{6,8}|\d{10,12}$</constant-value>
</constant>
<constant>
<constant-name>alphabetsOnly</constant-name>
<constant-value>^[A-Za-z]*$</constant-value>
</constant>
<constant>
<constant-name>alphabetsWithSpace</constant-name>
<constant-value>^[A-Za-z]{1}[A-Za-z ]*$</constant-value>
</constant>
<constant>
<constant-name>numbersWithHyphen</constant-name>
<constant-value>^[0-9]{1}[0-9-]*$</constant-value>
</constant>
<constant>
<constant-name>alphabetsWithHyphen</constant-name>
<constant-value>^[A-Za-z]{1}[A-Za-z-]*$</constant-value>
</constant>
<constant>
<constant-name>accountCode</constant-name>
<constant-value>^[\w]{1}[\w-]*$</constant-value>
</constant>
<constant>
<constant-name>numericMask</constant-name>
<constant-value>^[0-9]+[.]{0,1}[0-9]*$</constant-value>
</constant>
<constant>
<constant-name>empNameMask</constant-name>
<constant-value>^[a-zA-Z][a-zA-Z. ]*$</constant-value>
</constant>
<constant>
<constant-name>numericMaskWithoutDecimal</constant-name>
<constant-value>^[0-9]*$</constant-value>
</constant>
<constant>
<constant-name>nameMask</constant-name>
<constant-value>^[a-zA-Z]{1}[a-zA-Z0-9 &(_)-@]*$</constant-value>
</constant>
<constant>
<constant-name>shortNameMask</constant-name>
<constant-value>^[a-zA-Z]{1}[ a-zA-Z0-9&(_)-@]*$</constant-value>
</constant>
<constant>
<constant-name>bloodGroupMask</constant-name>
<constant-value>^[a-zA-Z][a-zA-Z0-9 +-]*$</constant-value>
<!--<constant-value>^[a-zA-Z]+[\w +()-]*$</constant-value>-->
</constant>
<constant>
<constant-name>dateFormat</constant-name>
<constant-value>dd-MM-yyyy</constant-value>
</constant>
<constant>
<constant-name>alphanumeric</constant-name>
<constant-value>^[\w]*$</constant-value>
</constant>
<constant>
<constant-name>alphanumericWithHyphen</constant-name>
<constant-value>^[\w]{1}[\w-]*$</constant-value>
</constant>
<!-- global constant for date format -->
</global>

<formset>
<form name="RegBean">
<field
property="name"
depends="required">
<arg0 key="RegBean.name"/>
</field>
<field
property="fname"
depends="required">
<arg0 key="RegBean.fame"/>
</field>
<field
property="phno"
depends="required">
<arg0 key="RegBean.phno"/>
</field>
<field
property="address"
depends="required">
<arg0 key="RegBean.address"/>
</field>
<field property="name" depends="minlength">
<arg0 key="RegBean.phno"/>
</field>
</form>
<!-- formset Code Contents Starts Here -->
<!-- Cause Of Loss Code Starts Here -->

<form name="CauseOfLossForm">
<field property="txtCauseofLossCode" depends="required">
<arg0 key="label.code"/>
</field>
<field property="txtCauseofLossDescription" depends="required">
<arg0 key="label.description"/>
</field>
</form>
<!-- Cause Of Loss Code Ends Here -->

<!-- Court Location Starts Here
<form name="CourtLocationForm">
<field property="courtTypeId" depends="selectrequired">
<arg0 key="label.courttype"/>
</field>
<field property="locationId" depends="selectrequired">
<arg0 key="label.courtLocation"/>
</field>
<field property="cboState" depends="selectrequired">
<arg0 key="label.courtState"/>
</field>
<field property="courtNo" depends="required">
<arg0 key="label.courtNo"/>
</field>
<field property="judgeId" depends="selectrequired">
<arg0 key="label.judgeName"/>
</field>
<field property="withEffFrom" depends="required">
<arg0 key="common.withEffectFrom"/>
</field>
<field property="withEffTo" depends="required">
<arg0 key="common.withEffectTo"/>
</field>
</form>
Court Location Ends Here -->

<!-- Delivery Mode Code Starts Here

<form name="DeliveryModeForm">
<field property="txtCode" depends="required">
<arg0 key="label.code"/>
</field>
<field property="txtDeliveryMode" depends="required">
<arg0 key="label.deliveryMode"/>
</field>
</form>
Delivery Mode Code Ends Here -->

<!-- Menu Form Validation Code Starts Here -->
<form name="MenuForm">
<field property="txtMenuName" depends="required">
<arg0 key="label.menuName"/>
</field>

</form>
<!-- Menu Form Validation Code Ends Here -->

<!-- Role Form Validation Code Starts Here -->
<form name="RoleForm">
<field property="txtRoleName" depends="required">
<arg0 key="label.roleName"/>
</field>
</form>
<!-- Role Form Validation Code Ends Here -->

<!-- User Role Form Validation Code Starts Here -->
<form name="UserRoleForm">
<field property="txtUserId" depends="required">
<arg0 key="label.userCode"/>
</field>
<field property="txtUserName" depends="required">
<arg0 key="label.userName"/>
</field>

</form>
<!-- User Role Form Validation Code Ends Here -->

<!-- Court Type Master Starts Here -->

<form name="CourtTypeMasterForm">
<field property="txtCourtTypeCode" depends="required">
<arg0 key="label.courtTypeCode"/>
</field>
<field property="txtCourtTypeName" depends="required">
<arg0 key="label.courtTypeName"/>
</field>
</form>

<!-- Court Type Master Ends Here -->

<!-- Judge Master Starts Here -->

<form name="JudgeMasterForm">
<field property="txtNewIcNo" depends="required">
<arg0 key="label.newICNo"/>
</field>
<field property="txtJudgeName" depends="required">
<arg0 key="label.judgeName"/>
</field>
</form>
<!-- Judge Master Ends Here -->

<!-- Checklist Group Code Starts Here
<form name="ChecklistGroupForm">
<field property="txtGroupCode" depends="required">
<arg0 key="label.groupCode"/>
</field>
<field property="txtGroupName" depends="required">
<arg0 key="label.groupName"/>
</field>
</form>
Checklist Group Code Ends Here -->

<!-- Proceeding Type Starts Here -->

<form name="ProceedingTypeForm">
<field property="txtProceedingTypeName" depends="required">
<arg0 key="label.proceedingTypeName"/>
</field>
</form>

<!-- Proceeding Type Ends Here -->

<!-- ChangeOfWorkshopForm Starts Here -->

<form name="ChangeOfWorkshopForm">
<field property="txtChgWorkshopCode" depends="required">
<arg0 key="label.chgWorkshopCode"/>
</field>
<field property="txtChgWorkshopName" depends="required">
<arg0 key="label.chgWorkshopName"/>
</field>
</form>

<!-- ChangeOfWorkshopForm Ends Here -->

</formset>
</form-validation>

my validation-rull xml file
-----------------------------
<!DOCTYPE form-validation PUBLIC
"-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
"http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
<!--
$Id: validator-rules.xml,v 1.2 2006/04/27 16:32:53 takezoe Exp $

This file contains the default Struts Validator pluggable validator
definitions. It should be placed somewhere under /WEB-INF and
referenced in the struts-config.xml under the plug-in element
for the ValidatorPlugIn.

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>

These are the default error messages associated with
each validator defined in this file. They should be
added to your projects ApplicationResources.properties
file or you can associate new ones by modifying the
pluggable validators msg attributes in this file.

# Struts Validator Error Messages
errors.required={0} is required.
errors.minlength={0} can not be less than {1} characters.
errors.maxlength={0} can not be greater than {1} characters.
errors.invalid={0} is invalid.

errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.
errors.float={0} must be a float.
errors.double={0} must be a double.

errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is an invalid credit card number.
errors.email={0} is an invalid e-mail address.

Note: Starting in Struts 1.2.0 the default javascript definitions have
been consolidated to commons-validator. The default can be overridden
by supplying a <javascript> element with a CDATA section, just as
in struts 1.1.

-->

<form-validation>

<global>

<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

<validator name="selectrequired"
classname="com.kgisl.kclaims.web.struts.validator.CommonValidator"
method="validateSelectRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
msg="errors.selectrequired">
<javascript>
<![CDATA[
function validateSelectRequired(form) {

var isValid = true;
var focusField = null;
var i = 0;
var fields = new Array();
var formName = form.getAttributeNode("name");


oSelectrequired = new selectrequired();
for (x in oSelectrequired) {
var field = form[oSelectrequired[x][0]];

if ((field.type == 'hidden' ||
field.type == 'text' ||
field.type == 'textarea' ||
field.type == 'file' ||
field.type == 'checkbox' ||
field.type == 'radio' ||
field.type == 'select-one' ||
field.type == 'password') &&
field.disabled == false) {


var value = '';

// get field's value
if (field.type == "select-one") {
var si = field.selectedIndex;

if (si >= 0) {
value = field.options[si].value;
}
} else if (field.type == 'checkbox' || field.type == 'radio') {
if (field.checked) {
value = field.value;
}
} else {
value = field.value;
}



if (trim(value).length == 0) {

if (i == 0) {
focusField = field;
}
fields[i++] = oSelectrequired[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++] = oSelectrequired[x][1];
isValid=false;
}

}
}
if (fields.length > 0) {
focusField.focus();
document.getElementById("statusMessage").innerHTML ='';alert(fields.join('\n'));

}
return isValid;
}

// Trim whitespace from left and right sides of s.
function trim(s) {
return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}
]]>
</javascript>
</validator>

<validator name="requiredif"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequiredIf"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

<validator name="validwhen"
msg="errors.required"
classname="org.apache.struts.validator.validwhen.ValidWhen"
method="validateValidWhen"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"/>


<validator name="minlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMinLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.minlength"
jsFunction="org.apache.commons.validator.javascript.validateMinLength"/>


<validator name="maxlength"
classname="org.apache.struts.validator.FieldChecks"
method="validateMaxLength"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.maxlength"
jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/>



<validator name="mask"
classname="org.apache.struts.validator.FieldChecks"
method="validateMask"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.invalid"/>


<validator name="byte"
classname="org.apache.struts.validator.FieldChecks"
method="validateByte"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.byte"
jsFunctionName="ByteValidations"/>


<validator name="short"
classname="org.apache.struts.validator.FieldChecks"
method="validateShort"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.short"
jsFunctionName="ShortValidations"/>


<validator name="integer"
classname="org.apache.struts.validator.FieldChecks"
method="validateInteger"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.integer"
jsFunctionName="IntegerValidations"/>



<validator name="long"
classname="org.apache.struts.validator.FieldChecks"
method="validateLong"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.long"/>


<validator name="float"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloat"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.float"
jsFunctionName="FloatValidations"/>

<validator name="double"
classname="org.apache.struts.validator.FieldChecks"
method="validateDouble"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.double"/>


<validator name="date"
classname="org.apache.struts.validator.FieldChecks"
method="validateDate"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.date"
jsFunctionName="DateValidations"/>


<validator name="intRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateIntRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="integer"
msg="errors.range"/>


<validator name="floatRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateFloatRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="float"
msg="errors.range"/>

<validator name="doubleRange"
classname="org.apache.struts.validator.FieldChecks"
method="validateDoubleRange"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends="double"
msg="errors.range"/>


<validator name="creditCard"
classname="org.apache.struts.validator.FieldChecks"
method="validateCreditCard"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.creditcard"/>


<validator name="email"
classname="org.apache.struts.validator.FieldChecks"
method="validateEmail"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.email"/>

<validator name="url"
classname="org.apache.struts.validator.FieldChecks"
method="validateUrl"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.url"/>

<!--
This simply allows struts to include the validateUtilities into a page, it should
not be used as a validation rule.
-->
<validator name="includeJavaScriptUtilities"
classname=""
method=""
methodParams=""
depends=""
msg=""
jsFunction="org.apache.commons.validator.javascript.validateUtilities"/>

</global>

</form-validation>



my resource
--------------------
# -- standard errors --
errors.header=<UL>
errors.prefix=<LI>
errors.suffix=</LI>
errors.footer=</UL>
# -- validator --
errors.invalid={0} is invalid.
errors.maxlength={0} can not be greater than {1} characters.
errors.minlength={0} can not be less than {1} characters.
errors.range={0} is not in the range {1} through {2}.
errors.required={0} is required.
errors.byte={0} must be an byte.
errors.date={0} is not a date.
errors.double={0} must be an double.
errors.float={0} must be an float.
errors.integer={0} must be an integer.
errors.long={0} must be an long.
errors.short={0} must be an short.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid e-mail address.
# -- other --
errors.cancel=Operation cancelled.
errors.detail={0}
errors.general=The process did not complete. Details should follow.
errors.token=Request could not be completed. Operation is not in sequence.
# -- welcome --
welcome.title=Struts Application
welcome.heading=Struts Applications in Netbeans!
welcome.message=It's easy to create Struts applications with NetBeans.


RegstrationForm.empid=empid
RegstrationForm.dept=dept
RegstrationForm.efname=efname
RegstrationForm.desig=desig
RegstrationForm.emname=emname
RegstrationForm.elname=elname
RegstrationForm.doorno=doorno
RegstrationForm.location=location
RegstrationForm.area=area
RegstrationForm.district=district
RegstrationForm.stat=stat
RegstrationForm.zipcode=zipcode
RegstrationForm.country=country
RegstrationForm.stdcode=stdcode
RegstrationForm.phno=phno
RegstrationForm.ccode=ccode
RegstrationForm.mobileno=mobileno
RegstrationForm.sex=sex
RegstrationForm.dd=dd
RegstrationForm.mm=mm
RegstrationForm.yyy=yyy


prompt.email=EMAIL



any one can help me ... friends..


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.

Bear in mind you've posted a *lot* of code and configuration here: it's best to create a sample that does not work as expected and post that, and remember to remove unnecessary comments, HTML, etc. that doesn't contribute to solving the problem. It's important to help people help you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation error
 
Similar Threads
Problem with struts messages
Problem with struts message
Error while starting tomcat server:no able to load Validator file
client side validation
validator problem