GeeCON Prague 2014*
The moose likes Struts and the fly likes both javascript and serverside validations running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "both javascript and serverside validations running" Watch "both javascript and serverside validations running" New topic
Author

both javascript and serverside validations running

Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
Hi all,

i am using javascript validation along with server side validation using struts.

the problem is that both validations are running one after the other.

how to control this so that only javascript validation runs? if javascript is disabled the serverside validations should take place.

thanks,
Seshu


Sree Jag<br />SCJP 1.4
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

Seshu,
I don't think you can. The sever side validation is supposed to be a fail safe for when javascript is disabled. As they should be checking for the same rules, it isn't a problem if both run.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
hi Jeanne,

But the problem is the html:errors tag present in the jsp displays the serverside errors too. we don't want both javascript and serversside errors to show up right?.

and also, the struts site says that the form will not be submitted if the javascript validation fails. but the form is getting submitted even if there are errors. i think that is the problem behind both validations being performed.

any ideas y the form is being submitted even if javascript validation fails?


Seshu
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30580
    
154

Seshagiri,
Are you using any other javascript on the page? If there are javascript errors, a form may submit regardless off the validation.

Also, can you post the line of code from the generated HTML (not the JSP) beginning with <form
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I agree with Jeanne. There is probably other javascript on the page that is causing the form to submit.


A good workman is known by his tools.
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Peter den Haan had given a solution to a similar problem some time back. Check if this applies to you.

Sheldon Fernandes
[ September 30, 2004: Message edited by: Sheldon Fernandes ]
Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
Hey all,
Yeah there r some javascript errors on the page. May be thts the reason y the form is getting submitted. Thanks for the replies..

Seshu.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: both javascript and serverside validations running