Submit is used for validation and after validation is passed it passes it to another form to enter into database.
Basically the reset works fine if I use it before using the submit button in the form. For instance,if on submit there is some error as the values have not passed a validation. There is a error pop up message shown and the values are retained in the field and Now if I use reset , all the values of the field do not go back to null.
So I made reset into a button which onclick event calls the reset() function and clears the form but I am sure that the code is not right as it is not working, I tired putting a alert message in my function to reassue that the function is being called but I think it is not.
I am not sure if its the best way to do it.
I want the whole form to refresh/ reload every time reset is clicked and all the fields to have no values.
I used the same code earlier with button, but unable to clear the form fields.
I will tell you once again:
Step 1: I entered some text in the form fields and i clicked on submit button, then its validated form fields, failed and returned back to the same page with old values. Step 2:When I clicked on the reset button, once again the action is calling without reset to null in the form, this shouldn't be happened.
I did the same thing what you suggested. but wasn't working properly. I used Struts 1...
If you're still looking for a different alternative, you may want to consider using the <html:cancel> tag. This causes a submit of the form without validation. You would then use the isCancelled() method of the Action class to determine whether the cancel button had been pressed and then clear all the ActionForm properties. Be aware that if you're using Struts 1.2.9 or above, you must specify cancellable="true" in the Action mapping for this action in the struts-config.xml file. [ March 19, 2008: Message edited by: Merrill Higginson ]