how to reset form fields in javascript

Posted by Abhi_patil under JavaScript on 6/5/2009 | Views : 7040 | Status : [Member] | Replies : 2
i have form contains textboxes and required field validators.

i have html reset button, when click on reset button then it reset only input fields it does not clear reqired field validator..




Responses

Posted by: Vuyiswamb on: 6/7/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Evening Abhi_patil

If you were using a Server side, it would have been easy , you would have used a Clear Property of the Textbox, but now that means in the Button Reset you have to set the Controls to an empty string like

Textbox1.text = "";


Thank you for Posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Anup1252000 on: 8/2/2009 [Member] Starter

Up
0
Down
write these lines of code


<script language="javascript" type="text/javascript">

// <!CDATA[

function Reset1_onclick() {
var text=document.getElementById('<%= TextBox1.ClientID %>');
text.value="";
}

// ]]>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Reset1" type="reset" value="reset" onclick="return Reset1_onclick()" />
</div>
</form>
</body>
</html>


https://wordpress.com/pages/anuphosur.wordpress.com

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response