| Author |
Reset Form with error messages as well
|
Dipali yadav
Greenhorn
Joined: May 21, 2012
Posts: 22
|
|
Hi,
when I click on reset button, it resets only fields but I want that it should reset error messages as well from the page.
Please help me out for this.
thanks...
|
 |
Mohana Rao Sv
Ranch Hand
Joined: Aug 01, 2007
Posts: 485
|
|
|
Then reload the page again all error message will be gone.
|
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
|
 |
Dipali yadav
Greenhorn
Joined: May 21, 2012
Posts: 22
|
|
May I know how to reload the page...............
This might be a silly question but I really don't know...
|
 |
Daniel Val
Ranch Hand
Joined: Jan 09, 2012
Posts: 39
|
|
Dipali yadav wrote:Hi,
when I click on reset button, it resets only fields but I want that it should reset error messages as well from the page.
Please help me out for this.
thanks...
This is what a <input type="reset"> button does. It will only reset the form fields.
So what you need to do:
- Create a <input type="button" onclick="someFunction" value="Reset"/>
- Define javascript function someFunction that will do the following:
a) reset the error messages
b) document.forms[0].reset(); // this is just like the reset button
how you do b) is clear, how you do a):
- When you render the page, put all your error messages wrapped in some tags that can be easily found in the DOM like
<span class="errorhere">error message</span>
- Then implement a) like that: find all the tags with class errorhere and remove all their children from the DOM. This will remove all the error messages. Don't do it by hand: use a Javascript framework like jQuery.
not sure about the syntax, but something like that:
jQuery('span.errorhere > *').remove();
|
 |
 |
|
|
subject: Reset Form with error messages as well
|
|
|