I called a class called test for my textbox. When I entered the first value for e.g. the first value as 4., then suddenly the output coming as 4.00
4.
4.00
What about something like this:
$(".test").keyup(function (event) { if ((pointPos = this.value.indexOf('.')) >= 0) $(this).attr("maxLength", pointPos+3); else $(this).removeAttr("maxLength"); });
Here is a working fiddle.