File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes form validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "form validation" Watch "form validation" New topic

form validation

syidah mk

Joined: Feb 03, 2005
Posts: 13

i need help... is it possible to
display the error in the form using out.println rather than
alert message box when validating a form using javascript ???
Florian Heinisch

Joined: Mar 03, 2005
Posts: 15
In your Servlet you have to check your form fields' content. If there is something the user did not enter correctly you just "build" the whole form again and place the error message(s) into the form where ever you want them to show up. So the user sees the same form plus your error message(s).
[ March 04, 2005: Message edited by: Florian Heinisch ]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
More likely this kinda behaviour is from server-side validation.
Preetham Chandrasekhar
Ranch Hand

Joined: Nov 05, 2003
Posts: 98
yup...u can do it before you save it to the db and check if its null...if it is...then send it back to the client stating that the following errors have to be entered.

"In theory, there is no difference between theory and practice. But, in practice, there is."<br /> - Jan L.A. van de Snepscheut
Annie Smith
Ranch Hand

Joined: Mar 05, 2005
Posts: 172
You could use Struts Validator for that.

Cheers!<br /><b>Annie</b>
I agree. Here's the link:
subject: form validation
It's not a secret anymore!