PageSourceSearch

https://www.hlusovice.eu/script/classes/forms/Validate.js

js hlusovice.eu collected 2026-10-09 17:11:38 UTC 3,539 bytes, 133 lines download raw bytes

1/* Form validation class */
2function Validate(_submitBtn, _waitMsg, _formName) {
3	
4	this.items = new Object();
5	this.checks = new Object();
6	this.radios = new Object();
7	this.password = '';
8	this.checkpassword = '';
9	this.passwordmessage = '';
10	this.active = true;
11	
12	this.submitBtn = (_submitBtn != undefined) ? _submitBtn : '';
13	this.waitMsg = (_waitMsg != undefined) ? _waitMsg : '...';
14	this.formName = (_formName != undefined) ? _formName : '';
15	this.tabBrowser = null;
16
17	
18	this.AddOption = function(_textfield, _message) {
19		
20		var type = $('[name='+_textfield+']', this.formName != '' ? 'form[name='+this.formName+']' : '').attr('type');
21		
22		switch(type) {
23			case 'radio' : this.AddRadio(_textfield, _message); break;
24			case 'checkbox' : this.AddCheckbox(_textfield, _message); break;
25			default: this.items[_textfield] = _message;	
26		}
27	}
28	
29	this.DropOption = function(_textfield) {
30		delete this.items[_textfield];
31		delete this.checks[_textfield];
32		delete this.radios[_textfield];
33
34		return this;
35	}
36
37	this.AddPassword = function(_password, _checkpassword, _message) {
38		this.password = _password;
39		this.checkpassword = _checkpassword;
40		this.passwordmessage = _message;
41	}
42	
43	this.DropPassword = function() {
44		this.password = '';
45		this.checkpassword = '';
46		this.passwordmessage = '';
47	}
48	
49	this.AddCheck = function(_checkbox, _message) {
50		this.checks[_checkbox] = _message;
51	}
52	
53	this.AddRadio = function(_radio, _message) {
54		this.radios[_radio] = _message;
55	}
56	
57	
58	this.Check = function() {
59		
60		if (this.active === false) return true;
61
62		if (this.submitBtn != '') {
63			var label = $('#'+this.submitBtn).val();
64			$('#'+this.submitBtn).attr('disabled', true);			
65			$('#'+this.submitBtn).val(this.waitMsg);
66		}
67
68		// textfields & controls
69		for (var i in this.items) {
70
71			if ($('[name='+i+']', this.formName != '' ? 'form[name='+this.formName+']' : '').val() == '') {
72				alert(this.items[i]);
73				this.SetFocus(i);
74				this.EnabeBtn(label);
75				return false;
76			}
77		} // for
78
79
80		// checkbox validate
81		for (var i in this.checks) {
82
83			if (!$('[name='+i+']', this.formName != '' ? 'form[name='+this.formName+']' : '').attr('checked')) {
84				alert(this.checks[i]);
85				this.SetFocus(i);
86				this.EnabeBtn(label);
87				return false;
88			}
89		}
90
91		// radio validate
92		for (var i in this.radios) {
93
94			if ($('[name='+i+']:checked', this.formName != '' ? 'form[name='+this.formName+']' : '').length === 0) {
95				alert(this.radios[i]);
96				this.SetFocus(i);
97				this.EnabeBtn(label);
98				return false;
99			}
100		}
101
102		// password match validate			
103		if (this.password != '') 
104			if ($('[name='+this.checkpassword+']', this.formName != '' ? 'form[name='+this.formName+']' : '').length && $('[name='+this.password+']', this.formName != '' ? 'form[name='+this.formName+']' : '').val() != $('[name='+this.checkpassword+']', this.formName != '' ? 'form[name='+this.formName+']' : '').val()) {
105				alert (this.passwordmessage);
106				this.SetFocus(this.password);					
107				this.EnabeBtn(label);
108
109				return false;
110			}
111	
112		return true;
113		
114	}
115	
116	this.EnabeBtn = function(label) {
117		
118		if (this.submitBtn != '') {
119			$('#'+this.submitBtn).attr('disabled', false);
120			$('#'+this.submitBtn).val(label);
121		}
122		
123	}
124	
125	this.SetFocus = function(tag) {
126		if (this.tabBrowser !== null) this.tabBrowser.Focus(tag);
127		else	{
128			$('[name='+tag+']').addClass('selectedTag');
129			$('[name='+tag+']').focus();
130		}
131	}
132	
133}

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.