I need assistance with resetting a text box client-side using JavaScript. I have tried multiple methods to reset the textbox, but none seem to be working.
cText = "";
document.getElementById("<%=txtText.ClientID %>").value = cText;
and
document.getElementById("<%=txtText.ClientID %>").value = "";
If anyone can provide help with this issue, it would be greatly appreciated.
Here is the code snippet:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript>
function validate() {
var cText = document.getElementById('<%=txtText.ClientID %>').value;
if (cText != "") {
alert("Text is not null.");
document.forms['UserMaster'].elements['txtText'].focus();
$("#<%=txtText.ClientID %>").val("");
return false;
}
return true;
};
</script>
</head>
<body>
<form id="form" runat="server">
<div class="page">
<asp:TextBox ID="txtText" runat="server"></asp:TextBox>
<br/>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" Font-Bold="true" OnClientClick="return validate()"
ForeColor="#9370DB" Height="23px" Width="65px" OnClick="btnSubmit_Click"
/>
<br />
</div>
</form>
</body>
</html>