PageSourceSearch

https://tri-facil.com/admin/scripts/common/validations.js?v=1776793854

js tri-facil.com collected 2026-10-02 01:46:47 UTC 3,064 bytes, 124 lines download raw bytes

1// oxlint-disable no-unused-vars
2let isThereAnError = false;
3let somethingIsChanged = false;
4const cssClass = 'input-error';
5let recursive = '';
6
7$(document).ready(function(){
8	$('input, select, textarea').change(function(e) {
9		somethingIsChanged = true;
10
11        if(isThereAnError === true){
12			if(e.target.id === ''){
13				$('.validation').html('');
14				isThereAnError = false;
15			}
16			else{
17				removeError(e.target.id);
18			}
19		}
20		if(recursive !== ''){
21			$(recursive).removeClass(cssClass);
22			recursive = '';
23		}
24    });
25	$('input, textarea').keyup(function(e) {
26		somethingIsChanged = true;
27		
28        if(isThereAnError === true){
29			if(e.target.id === ''){
30				$('.validation').html('');
31				isThereAnError = false;
32			}
33			else{
34				removeError(e.target.id);
35			}
36		}
37		if(recursive !== ''){
38			$(recursive).removeClass(cssClass);
39			recursive = '';
40		}
41    });
42});
43
44function showValidationMsj(input, box, msj, todos = false){
45	$(input).addClass(cssClass);
46	$(box).html(msj);
47	isThereAnError = true;
48	if(todos) recursive = input;
49}
50
51function checkTel(tel){
52	const telPattern =/^[0-9-+ ]{8,20}$/;
53	return telPattern.test(tel);
54}
55
56function checkTelWithArea(tel, area = '504'){
57	const telPattern = new RegExp('^('+area+')([0-9]{8})$', "g");
58	return telPattern.test(tel);
59}
60
61function checkEmail(email){
62	const emailPattern = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$/;
63	return emailPattern.test(email);
64}
65
66function checkName(name){
67	const namePattern = /^[a-zA-ZñÑáéíóúüÁÉÍÓÚÜ ']{3,50}$/;
68	return namePattern.test(name);
69}
70
71function checkPassword(password){
72	const passwordPattern = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,16}$/;
73	return passwordPattern.test(password);
74}
75
76function checkString(string){
77	if(string === null || string === undefined || string.length === 0 || /^\s+$/.test(string)) return false;
78	return true;
79}
80
81function checkNumber(num){
82	if(num === null || num === undefined || num.length === 0 || /^\s+$/.test(num) || isNaN(num)) return false;
83	return true;
84}
85
86function checkSelect(val, defaultValue = 'x'){
87	if(val === defaultValue || val === null || val === undefined || (typeof defaultValue === 'number' && isNaN(val))) return false;
88	return true;
89}
90
91function checkNickname(nickname){
92	const nicknamePattern = /^[A-Za-z0-9_-]{4,25}$/;
93	return nicknamePattern.test(nickname);
94}
95
96function checkDate(date){
97	const datePattern = /^\d{4}-\d{2}-\d{2}$/;
98	return datePattern.test(date);
99}
100
101function checkTime(time){
102	const timePattern = /^\d{2}:\d{2}$/;
103	return timePattern.test(time);
104}
105
106function checkUrl(url){
107	// URL must start with https:// and optional end width a slash
108	const urlPattern = /^https:\/\/[a-zA-Z0-9-._~:/?#[\]@!$&'()*+,;=]+\/?$/;
109	return urlPattern.test(url);
110}
111
112function removeError(x){
113	$('#' + x).removeClass(cssClass);
114	$('.validation').empty();
115	isThereAnError = false;
116}
117
118function showHidePassWord(checked, inputIds){
119	const value = checked ? 'text' : 'password';
120
121	for(let i = 0; i < inputIds.length; i++){
122		$(inputIds[i]).attr('type', value);
123	}
124}

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.