I have an input field that is used to insert a dollar amount. If the user types in “100” or “100.” I want to add two decimal places to the value using the toFixed(2) method.
Here is an example
This is what I have tried:
var j$ = jQuery.noConflict();
j$(document).ready(function() {
j$('#ccAmt').blur(function() {
j$(this).val(j$(this).val().toFixed(2));
});
});
I found several examples on the forum, but everything I tried didn’t work. What am I missing?
Thanks.
Is
.val()returning a Number? Try: