File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to do Client-side validation in Javascript in Struts Form Submission. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to do Client-side validation in Javascript in Struts Form Submission. " Watch "How to do Client-side validation in Javascript in Struts Form Submission. " New topic
Author

How to do Client-side validation in Javascript in Struts Form Submission.

camey bensingh
Greenhorn

Joined: Apr 03, 2008
Posts: 3
How to do Client-side validation in Javascript. After form submission the control go to the Javascript validation and fetch information from Struts Form and do the validations.Give me a example.
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

camey camey,
Welcome JavaRanch.

We're pleased to have you here with us , but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policyand adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.


Well for your question you have to understand how the things work. When you press the submit button on the JSP the control goes to any javascript methods that are onclick of the button. If there are no javascript methods then the form is submitted and it Struts fills your for beans and finally control goes to the execute method of your action.

Now, if you want to do some client side validation using javascript on click of submit then you should have the data required for validation already on the document precisely the jsp. You can do this by dumping the data as hidden tags or other means.

But, if you want to go to javascript and fetch data from server and then perform client side validation then it is not feasible and moreover it no longer can be said as client side validation as you are hitting the server.


Considering that you have all the data required already on the form you can do client side validation.

E.g. the following script verifies that there is atleast one element selected before going to fetch data for that object




Hope that helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to do Client-side validation in Javascript in Struts Form Submission.
 
Similar Threads
Servlet filter being invoked twice per request by Container.
Have any problem using validator
How to use Javascript validation in struts?
struts validator
Struts 1.2 - Client and Server-side validations