jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Reset button & Validation Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Reset button & Validation Error" Watch "Reset button & Validation Error" New topic

Reset button & Validation Error

Satish Kulkarni
Ranch Hand

Joined: Jul 19, 2003
Posts: 60
I have a form "ModfyUserForm" with "Submit" button and a "Reset" button. The form is prepopulated depending on what user is selected from a dropdown list. When you edit a certain field in the form and before clikcing Submit you click Reset my previous data is loaded back in the form. But while modifying if any field(like emailaddress field) is empty I throw a Validation Error.
But after the Validation Error if I click the Reset button the old values are not retrieved and the form is not populated with the old data. Is there a way to make this...if could you please let me know.
Thanks in advance.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6328

Reset restores fields with the values they had when the page was originally loaded. When you come back with validation errors, the data that you validated now become the original values. The values that you had before validation are lost. The only way you can restore the values you really wanted would be to change your reset button to a submit button and pull the original values back into the form fields on the server side. That is, instead of
<html:reset />
you would have

Junilu - [How to Ask Questions] [How to Answer Questions]
I agree. Here's the link: http://aspose.com/file-tools
subject: Reset button & Validation Error
It's not a secret anymore!