Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call javascript for textchanged event in htmltextbox?

I've got two html textboxes (txtFrom and txtTo) which is read-only. These two textboxes are used to show dates from datepicker.

My scenario is when txtTo textbox is filled with date i want to call a javascript which subtracts the two dates (txtTo - txtFrom) and enter the result in another textbox named txtDays.

How can i do this? I can't call onkeypress or onkeyup event since the textbox is read-only.

like image 221
ksg Avatar asked Nov 16 '25 07:11

ksg


1 Answers

You can use onchange event of javascript.

In html Section

<asp:TextBox ID="txtTo" runat="server" onchange="DateComparisionJavascriptFun();"></asp:TextBox>

In Javascript Block

<script type="text/javascript">
function DateComparisionJavascriptFun()
{
   alert("Validate dates here.");
}    
</script>
like image 188
Adil Avatar answered Nov 17 '25 22:11

Adil