- $(function () {
- var i = 0;
- $("body").find("input[type='text']").each(function () {
- i++;
- if (i > 2 && i < 8) {
- enforceNum($(this));
- return;
- }
- if (i > 12) {
- enforceNum($(this));
- return;
- }
- });
- function enforceNum(_node) {
- _node.live("keyup blur", function () {
- $(_node).val($(_node).val().replace(/[^0-9-]+/, ''));
- });
- }
- });
- //该片段来自于http://www.codesnippet.cn/detail/121220137973.html
来源: http://www.codesnippet.cn/detail/121220137973.html