I have a requirement that is when user entering text in the textbox i want to show a message (not alert box, this is asp: lable) i.e if user enter "x" in the textbox then i want show a message not after completion of text and not like ontextchanged event. If user cleans textbox then i don't want to show message.
0
votes
2 Answers
0
votes
You may try something like this:
Your textbox:
<asp:TextBox ID="TextBox1" runat="server" onKeyUp="my_function(this);"></asp:TextBox>
where your function my_function() is defined as follows:
<script type="text/javascript">
function my_function(el) {
var val = this.value;
if(val && val!="") {
// Hide your message
// ....
} else {
// Show your message
// ....
}
}
</script>
Hope this helps
keypressevent? I.e., on each keystroke check the current value of the field and decide what (if any) message to display within another element? - nnnnnn