Hi makumbi,
You need call JavaScript inside the document ready event handler and the proper jquery selector need to use.
Please refer below sample.
HTML
<asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$('[id*=txtAmount]').keyup(function (event) {
// skip for arrow keys
if (event.which >= 37 && event.which <= 40) return;
// format number
$(this).val(function (index, value) {
return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
});
});
});
</script>
Screenshot