-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathval_0001.js
114 lines (113 loc) · 3.58 KB
/
val_0001.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// javascript:
// -----------------------------------------------------------------------
// jsMyLib Version: 0.1.2 Release Date: 20140227
// © Copyright 1999-2023 Manu Herrán
// Free download source code:
// https://manuherran.com/
// -----------------------------------------------------------------------
// jsMyLib_val_0001_isDomain
// jsMyLib_val_0001_isEmail
// jsMyLib_val_0001_isAlphanumeric
// jsMyLib_val_0001_isNumeric
// jsMyLib_val_0001_isEmpty
// jsMyLib_val_0001_containsChar
// jsMyLib_val_0001_isNumber
// jsMyLib_val_0001_isGT
// jsMyLib_val_0001_isLT
// jsMyLib_val_0001_checkboxAll
// jsMyLib_val_0001_stripHtmlTags
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isDomain(campo) {
if (/^\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(campo))
return true;
else
return false;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isEmail(campo) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(campo))
return true;
else
return false;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isAlphanumeric(campo) {
re = new RegExp("[^A-Za-z0-9_]")
if (re.test(campo))
return false;
else
return true;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isNumeric(campo) {
re = new RegExp("[^0-9]")
if (re.test(campo))
return false;
else
return true;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isEmpty(campo) {
return (campo == '');
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_containsChar(campo, caracter) {
var length = campo.length;
var i = 0;
while (i < length) {
if (campo.charAt(i) == caracter) return true;
i++;
}
return false;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isNumber(campo) {
var length = campo.length;
var i = 0;
while (i < length) {
if (
(campo.charAt(i) != "0") &&
(campo.charAt(i) != "1") &&
(campo.charAt(i) != "2") &&
(campo.charAt(i) != "3") &&
(campo.charAt(i) != "4") &&
(campo.charAt(i) != "5") &&
(campo.charAt(i) != "6") &&
(campo.charAt(i) != "7") &&
(campo.charAt(i) != "8") &&
(campo.charAt(i) != "9")
)
return false;
i++;
}
return true;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isGT(campo, valor) {
if (campo > valor)
return true;
else
return false;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_isLT(campo, valor) {
if (campo < valor)
return true;
else
return false;
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_checkboxAll() {
for (var i=0;i<document.forms[0].elements.length;i++) {
var myItem = document.forms[0].elements[i];
if (myItem.name != 'selectall')
myItem.checked = document.forms[0].selectall.checked;
}
}
// -----------------------------------------------------------------------
function jsMyLib_val_0001_stripHtmlTags(cadena) {
var regExp = /<\S[^>]*>/g;
// preg_replace("/<.+?>/", "", $cadena);
return cadena.replace(regExp, "");
}
// -----------------------------------------------------------------------