Skip to content

Instantly share code, notes, and snippets.

@theotherzach
Last active August 29, 2015 13:57
Show Gist options
  • Save theotherzach/9786997 to your computer and use it in GitHub Desktop.
Save theotherzach/9786997 to your computer and use it in GitHub Desktop.
function stripCommas(input) {
return input.replace(/,/, '');
}
function ExpenseForm($el) {
$el.on('submit', clean)
function clean() {
$el.find('input[type=text]').each(function (index, field) {
field.value = stripCommas(field.value);
});
}
}
new ExpenseForm($('#expense-form'));
//vs:
$('#expense-form').on("submit", function (e) {
$(this).find('input[type=text]').each(function () {
this.value = this.value.replace(/,/, '')
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment