Reputation: 167
Can anyone tell me what the issue is with this JQuery? It isn't firing at all.... the txtBoxCost is the name of the textbox I am wanting to currency format.
$('.txtBoxCost').blur(function () {
$('.txtBoxCost').formatCurrency();
});
Maybe it is something simple I am just looking over or I am coming at formatting this field from the wrong direction.
Example valid field: $1,234,300.09
Updated:
<asp:TextBox ID="txtBoxCost" runat="server" ClientIDMode="Static"></asp:TextBox>
$('#txtBoxCost').blur(function () {
$(this).formatCurrency();
});
Libraries:
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<link rel="stylesheet" href="//jquery-formatcurrency.googlecode.com/svn/trunk/jquery.formatCurrency.js" />
Upvotes: 0
Views: 50
Reputation: 743
Is this what you are looking for.
Using ID:
HTML Code -
<input name="txtBoxCost" type="text" id="txtBoxCost" />
jQuery Code-
$('#txtBoxCost').blur(function () {
$(this).formatCurrency();
});
Working fiddle - http://jsfiddle.net/Ashish_developer/cqsbkru1/
Using Name:
HTML Code -
<input type='text' name='txtBoxCost'/>
jQuery Code -
$("input[name='txtBoxCost']").blur(function () {
$(this).formatCurrency();
});
Working fiddle - http://jsfiddle.net/Ashish_developer/L0ouvrxu/
Using Class:
HTML Code -
<input type='text' class ='txtBoxCost'/>
jQuery Code -
$('.txtBoxCost').blur(function () {
$(this).formatCurrency();
});
Working fiddle - http://jsfiddle.net/Ashish_developer/hxqzwj32/
Upvotes: 1