I'm trying to clear an ASP.NET Textbox, set to MultiLine (textarea in other words) when the user changes a project, here is the drop down list:
<label id="Label1" class="lbl">Project</label>
<asp:DropDownList ID="ddlProjectList" DataTextField="ClientProjectTitle"
DataValueField="ProjectID" AppendDataBoundItems="true" CssClass="ddl"
AutoPostBack="true" ValidationGroup="Projects" runat="server">
<asp:ListItem Text="-- select --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvProjectList" ControlToValidate="ddlProjectList"
InitialValue="0" Text="(required)" ErrorMessage="Select a project"
Display="Dynamic" ValidationGroup="Projects"
CssClass="error" runat="server"></asp:RequiredFieldValidator>
Here is the jQuery:
<script type="text/javascript">
$(document).ready(function() {
$('select[name*="ddlProjectList"]').change(function() {
$('textarea[name*="txtDescription"]').attr('value', '');
});
});
</script>
Before people respond, I have tried it with just .val(''); - and here is the textbox I'm trying to clear:
<label class="lbl">Description</label>
<asp:TextBox ID="txtDescription" TextMode="MultiLine" Rows="5"
CssClass="long-textbox-ml" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvDescription" ControlToValidate="txtDescription"
Text="(required)" ErrorMessage="Enter a description" Display="Dynamic"
ValidationGroup="Projects"
CssClass="error" runat="server"></asp:RequiredFieldValidator>
Any ideas why it is not working? I have stepped through it in Chrome and the event is firing.