I don't think so, Rick.  The javascript effectively mimics a user
manually clearing out all the fields on the form.  Once the form is
submitted, the new values (empty unless the user put something in after
invoking resetForm) will populate the formbean prior to invoking
validate.  Upon failing validation, those same values will be
presented to the user with the error message, if any.

Try it and see.

-- Jim

Rick Reumann <[EMAIL PROTECTED]> writes:

> The problem (from what I can gather) using this javascript approach is
> that it really isn't clearing out what is in memory. So for example
> say you call this function and the form clears out but the user types
> in something in the wrong format, when he now submits and gets back
> the validation errors it will also include stuff filled in the form
> that was there before this javascript function was called. I'm pretty
> sure this is what would happen but I could be wrong.
> 
> On Friday, April 12, 2002, 10:09:35 AM, Jim wrote:
> 
> JC> Gross, but effective:
> 
> JC> <script language="JavaScript">
> JC>     <!--
> JC>     function resetForm()
> JC>     {
> JC>       var f = document.forms[0]
> JC>       for (var i=0; i<f.length; ++i) {
> JC>         if (f.elements[i].type != "hidden") {
> JC>           f.elements[i].value = '';
> JC>         }
> JC>       }
> JC>       f.elements[0].focus();
> JC>     }
> JC>     // -->
> JC> </script>
> 
> JC> -- Jim
> 
> JC> Rick Reumann <[EMAIL PROTECTED]> writes:
> 
> >> If the user submits a form and some server side validation is done and
> >> the jsp form returns to the user with some validation, what is the
> >> best way to allow the user to clear the form and start over. Having a
> >> <html:reset> button whill only clear new things they enter, and
> >> refreshing is currently returning the same form with the same
> >> validation errors. I was thinking maybe having a button labeled
> >> "reset" but what it actually does is submit to an action that clears
> >> out all the fields and then returns you? Is this a good way to do it,
> >> or is there a better way with struts?
> >> 
> >> Thanks for any feedback.
> >> 
> >> 
> >> -- 
> >> 
> >> Rick
> >> mailto:[EMAIL PROTECTED]
> >> 
> >> "Why do people in ship mutinies always ask for 'better treatment'? I'd
> >> ask for a pinball machine, because with all that rocking back and
> >> forth you'd probably be able to get a lot of free games." 
> >>   -Jack Handey
> >> 
> >> 
> >> --
> >> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> >> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 
> 
> -- 
> 
> Rick
> mailto:[EMAIL PROTECTED]
> 
> "The difference between a man and a boy is, a boy wants to grow up to
> be a fireman, but a man wants to grow up to be a giant monster
> fireman." 
>   -Jack Handey
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

-- 
Jim Crossley
http://www.lads.com/~jim

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to