PageSourceSearch

https://itss.cn/zbxUI/js/zbx-extend-jquery-util.js

js itss.cn collected 2026-10-05 06:05:30 UTC 2,488 bytes, 88 lines download raw bytes

1/**
2 * dchen 2015-12-02 Jquery扩展:输入数字校验不通过时,自动重置光标,比如输入123a时,当输入完a会自动删除a,小数位数同理
3 * eq:$(this).changeNotFormatebleWord(2) 输入框要求保留两位小数
4 */
5(function($) {
6	jQuery.fn.extend({
7		"changeNotFormatebleWord" : function(doubleLimit) {
8
9			var input = this.val() + '';
10			if (input == null || input == '') {
11				return;
12			}
13			// 替换不符合数字规则的字符。
14			input = input.replace(/[^\d+(.^\d{1,3})]/g, '');
15			input = input.replace(new RegExp(',','gm'),'');//替换全部,
16			input = input.replace('。', '.');
17			// 判断是否为有效数字,为零,不通过。各参数:1.报错信息。2.输入值。3.小数点后的限制位数。
18			if (input[0] == '.') {
19				input = '0';
20			}
21
22			var r = new RegExp("[.]", "gi");
23			if (input.match(r) != null && input.match(r).length > 1) {
24				input = input.replace(r, '');
25			}
26
27			if (input < 1 && input > 0) {
28				input = (input + '').replace(/^0+\./g, '0.');
29			} else if (parseInt(input) == 0 && (input + '').indexOf('.') < 0) {
30				input = 0;
31			} else {
32				input = input.match(/^0+[1-9]+/) ? input = input.replace(
33						/^0+/g, '') : input;
34			}
35
36			var idx = (input + '').indexOf(".");
37			if (idx > 0) {
38				var n = input.length - idx - 1;
39				if (doubleLimit < n) {
40					var e = Math.pow(10, doubleLimit);
41					input = Math.round(input * e) / e;
42				}
43			}
44			if (doubleLimit == 0) {
45				input = parseInt((input + '').replace('.', ''));
46			}
47			// 加此判断,主要是放置在未改变值的按键事件下重置光标
48			if (input != (this.val() + '')) {
49				this.val(input);
50			}
51		},
52		// 输入框不能写0
53		"notZero" : function() {
54			var input = this.val() + '';
55			if (input == null || input == '') {
56				return;
57			}
58			if (input == '0'||Number(input)==0) {
59				this.val('');
60			}
61		},
62		// 输入框不能写0和-
63		"notZeroAndJ" : function() {
64			var input = this.val() + '';
65			if (input == null || input == '') {
66				return;
67			}
68			if (input == '0'||Number(input)==0) {
69				this.val('');
70			}
71			if (input == '-') {
72				this.val('');
73			}
74		},
75		"notZeroAndHund" : function() {
76			var input = this.val() + '';
77			if (input == null || input == '') {
78				return;
79			}
80			if (input == '0'||Number(input)==0) {
81				this.val('');
82			}
83			if (Number(input)>100) {
84				this.val('');
85			}
86		}
87	});
88})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.