Skip to content

Instantly share code, notes, and snippets.

@tarto-dev
Created April 8, 2015 16:05
Show Gist options
  • Select an option

  • Save tarto-dev/8f50c2ce44e92cfc7678 to your computer and use it in GitHub Desktop.

Select an option

Save tarto-dev/8f50c2ce44e92cfc7678 to your computer and use it in GitHub Desktop.
function FormatNumber(val) {
var split = val.split('.');
if (split.length > 1) return OnlyNumbersAllowed(split[0]) + '.' + OnlyNumbersAllowed(split[1]);
else return OnlyNumbersAllowed(split[0]);
}
function OnlyNumbersAllowed(val) {
return val.replace(/\D/g, '');
}
(function ($) {
"use strict";
$('#edit-user-invest').keyup(function (e) {
$(this).val(FormatNumber($(this).val()));
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment