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
you can use the maxLength attribute for that, try
$(".test").keyup(function (event) { var last = $(this).val()[$(this).val().length - 1]; if (last == '.') { $(".test").attr("maxlength", $(this).val().length+2); } });