$("#Lat").on("keypress keyup blur",function (event) { $(this).val($(this).val().replace(/[^0-9\.]/g,'')); if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) { event.preventDefault(); } }); $("#Lng").on("keypress keyup blur",function (event) { $(this).val($(this).val().replace(/[^0-9\.]/g,'')); if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) { event.preventDefault(); } });
var val = $(this).val(); // the decimal entered var desired_length = 12; // the length it should 'pad' to - that's the correct term for (var i = val.length; i < desired_length; i++) { val += '0'; }
$(this).val(val);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)