ContactUs

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

How client side validation is enabled on a JSP form?

In order to enable client side validation in Struts, first we need to enable validator plug-in in struts-config.xml file. This is done by adding following configuration entries in this file:

[xml]

<!–  Validator plugin –>

<plug-in className=”org.apache.struts.validator.ValidatorPlugIn”>

<set-property

property=”pathnames”

value=”/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml”/>

</plug-in>

[/xml]

Then Validation rules are defined in validation.xml file. If a form contains email field and we want to enable client side validation for this field, following code is added in validation.xml file:

[xml]

<form name=”testForm”>

<field  property=”email”

depends=”required”>

<arg key=”testForm.email”/>

</field>

</form>

[/xml]

Related Posts Plugin for WordPress, Blogger...
Flag Counter