|
Enabling Client Side Validation
The validation framework also gives the flexibility to use it on Client Side. The framework automatically generates the browser specific JavaScript and validate the data only at the client side. Although it has some disadvantages as the client side validations can be turn off by browser settings and also it is visible to the client. It also has some advantages like it reduces the network congestion as the form is not submitted with the wrong data again and again and only the validated data is submitted. It is also advisable if you are using the client side validation scripts then also use the validation at the server side so that two way check will maintain the data integrity fully.
The following code if placed in the jsp file will generate the java script at the client side for the specified form based on the validations.xml file.
<html:javascript formName="inputForm"/>
To call the validation routines call the onSubmit=validateXXX(this) whereas XXX stands for the form name. In our case it is inputForm. So the code is as follows :-
<html:form action="/validate.do" method="post" onSubmit="validateInputForm(this);"> |