So far I've been trying like this, but it did not work out:
$('.peso').keyup(function () {
var v = this.value,
integer = v.split('.')[0];
v = v.replace(/\D/g, "");
v = v.replace(/^[0]+/, "");
if (v.length <= 3 || !integer) {
if (v.length === 1) v = '0.00' + v;
if (v.length === 2) v = '0.0' + v;
if (v.length === 3) v = '0.' + v;
} else { v = v.replace(/^(\d{1,})(\d{3})$/, "$1.$2");}
this.value = v;});
HTML:
<p><label>Capacacidade</label></p>
<div class="input-group has-success">
<input type="text" name="txtcapac" placeholder="Capacidade em Kg" class="peso form-control"/>
<div class="input-group-addon"><span>Kg</span></div>