im trying to make input that automaticaly change to decimel while typing number but fixed with 2 decimel point only. please help me , because im still new with jquery
my code :
$.fn.billFormat = function() {
$(this).keyup( function( e ){
if( isNaN(parseFloat(this.value )) ) return;
this.value = parseFloat(this.value).toFixed(2);
});
return this;
}
$('#ENQUIRY_PREPAIDBILL .bill_issued').billFormat();
i want the output to be like this
0.00 <—— default value
0.01 <—— typing 1
0.10 <—— typing 0
1.00 <—— typing 0
Here is the demo.