Hi everyone,
This is the scenario:
I have two button - Submit and Reset
Submit is used for validation and after validation is passed it passes it to another form to enter into database.
Bascially 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.
I am new with form validation. I checked online and it said that reset will not clear if we have used submit and we need to use javascript to do it.
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 fucntion to reassue that the function is being called but I think it is not.
Posting my code
[Code]
<INPUT id=reset1 name=reset1 type =button value=Reset onClick="reset( )">
<Script>
function reset()
{
alert ("all values shall be cleared now");
document.frmUse r.name = "" ;
document.frmUse r.user = "" ;
document.frmUse r.contactNumber = "";
document.frmUse r.email = "" ;
}
</Script>
I am not sure if its the best way to do it.
I want the whole form to refresh/ reload everytime reset is clicked and all the fields to have no values.
Thanks for the help in advance.
Sree
This is the scenario:
I have two button - Submit and Reset
Submit is used for validation and after validation is passed it passes it to another form to enter into database.
Bascially 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.
I am new with form validation. I checked online and it said that reset will not clear if we have used submit and we need to use javascript to do it.
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 fucntion to reassue that the function is being called but I think it is not.
Posting my code
[Code]
<INPUT id=reset1 name=reset1 type =button value=Reset onClick="reset( )">
<Script>
function reset()
{
alert ("all values shall be cleared now");
document.frmUse r.name = "" ;
document.frmUse r.user = "" ;
document.frmUse r.contactNumber = "";
document.frmUse r.email = "" ;
}
</Script>
I am not sure if its the best way to do it.
I want the whole form to refresh/ reload everytime reset is clicked and all the fields to have no values.
Thanks for the help in advance.
Sree
Comment