• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic