Created
February 20, 2013 08:02
-
-
Save cuheguevara/4993810 to your computer and use it in GitHub Desktop.
Membuat File input hanya bisa memasukan Bilangan,
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function ($) { | |
$.fn.forceNumeric = function () { | |
return this.each(function () { | |
$(this).keyup(function() { | |
if (!/^[0-9]+$/.test($(this).val())) { | |
$(this).val($(this).val().replace(/[^0-9]/g, '')); | |
} | |
}); | |
}); | |
}; | |
}); | |
// Usage example: $('input.numeric').forceNumeric(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment