I am using below snippet:
<body>
<form id="form1" runat="server">
<div>
<input type="text" name="txtText" value=" " />
<asp:TextBox ID="txtData" runat="server" />
<asp:Button ID="btn" Text="Submit" OnClientClick="GetData()" runat="server"
onclick="btn_Click" />
</div>
<script>
function GetData() {
$('[id$=txtData]').val(escape($('input[name="txtText"]').val()))
//$('input[name="txtText"]').val('')
}
</script>
</form>
</body>
When I input some data like "<h4>Test</h4>
" it throws an exception, however, the code is working fine when the line //$('input[name="txtText"]').val('')
is un-commented.
Can somebody please help me here and explain what is really happening here?