I want to get the text value of a textbox from javascript. The textbox has a watermark extender attached to it. So while taking the value from javascript, if the textbox is empty then also we are getting that water marktext.
Our markup is like
<asp:TextBox ID="txtname" runat="server" MaxLength="30"></asp:TextBox>
<asp:TextBoxWatermarkExtender ID="wmname" runat="server" TargetControlID="txtname"
WatermarkText="Name" WatermarkCssClass="txt">
</asp:TextBoxWatermarkExtender>
JS:
$('input').blur(function() {
alert($(this).val());
});
On the blur event if we didn’t enter any value , then also its alerting “Name”.
Is there any way to get the exact text of textbox ie not the watermark text from javacript?
In the
wrapper behavior, there is a property _isWatermarked that we can use to check whether the TextBox is watermarked.Script:
Controls: