PageSourceSearch

https://www.foodinspiration.com/js/formvalidation.js?v=2

js foodinspiration.com collected 2026-09-24 08:53:14 UTC 3,945 bytes, 173 lines download raw bytes

1// Form validation
2function checkField(target) {
3	if($(target).hasClass('ess')) {
4		if ($(target).val() == '') {
5			$(target).addClass('error');
6			$(target).removeClass('ok');
7			error = 1;			
8		} else {
9			$(target).removeClass('error');
10			$(target).addClass('ok');
11		}
12		
13		if ($(target).attr('inputtype') !== undefined) {
14			var inputtype = $(target).attr('inputtype');
15			if (inputtype == 'email') {
16				if(!valMail($(target).val())) {
17					$(target).addClass('error');
18					$(target).removeClass('ok');
19					error = 1;
20					
21				} else {
22					$(target).removeClass('error');
23					$(target).addClass('ok');
24				};
25				
26			}
27		}
28		
29		
30	}
31}
32function validateForm(target) {
33	var error = 0;
34	$(target).find('input.ess:visible').each(function(index) {
35		//Controleer of de eerdere tabel niet de class 'by2' heeft, by2 moet namelijk ingevult worden door de monteur
36		
37	    
38		if ($(this).val() == '') {
39			$(this).closest('.form-group').addClass('has-error');
40			error = 1;			
41		} else {
42			$(this).closest('.form-group').removeClass('has-error');
43		}
44		
45		
46		if($(this).attr('type') == 'radio') {
47			thisId = $(this).attr('id');
48			if(!$('input[name='+thisId+']:checked').doesExist()) {
49				$('input[name='+thisId+']').closest('.radio').addClass('has-error');
50				error = 1;
51			} else {
52				$('input[name='+thisId+']').closest('.radio').removeClass('has-error');
53			}
54			
55		}	
56		
57		if($(this).attr('type') == 'checkbox') {
58			thisId = $(this).attr('id');
59			if(!$(this).is(':checked')) {
60				$(this).closest('.checkbox').addClass('has-error');
61				error = 1;
62			} else {
63				$(this).closest('.checkbox').removeClass('has-error');
64			}
65			
66		}	
67		if ($(this).attr('inputtype') !== undefined) {
68			//Check op type
69			var inputtype = $(this).attr('inputtype');
70			if (inputtype == 'date') {
71				if(!valDate($(this).val())) {
72					$(this).closest('.form-group').addClass('has-error');
73					error = 1;
74				} else {
75					$(this).closest('.form-group').removeClass('has-error');
76				};
77			}
78			if (inputtype == 'email') {
79				if(!valMail($(this).val())) {
80					$(this).closest('.form-group').addClass('has-error');
81					error = 1;
82					
83					
84					
85					
86				} else {
87					//$(this).removeClass('error');
88				};
89				
90			}
91			
92			if (inputtype == 'password') {
93				if($(this).val() != $('input[name=password_check]').val()) {
94					$(this).addClass('error');
95					$('input[name=password_check]').addClass('error');
96					error = 1;
97				} else {
98					//$(this).removeClass('error');
99				};
100			}
101			
102		}
103		
104  	});	
105	
106	
107	$(target).find('textarea.ess:visible').each(function(index) {
108		if ($(this).closest('table').attr('class') != 'by2') {
109		 if ($(this).val() == '') {
110			$(this).closest('.form-group').addClass('has-error');
111			error = 1;			
112		} else {
113			$(this).closest('.form-group').removeClass('has-error');
114		}
115		}
116	});
117	$(target).find('div.ess:visible').each(function(index) {
118		 if ($(this).html() == '') {
119			$(this).parent().addClass('errorline');
120			error = 1;			
121		} else {
122			$(this).parent().removeClass('errorline');
123		}
124	});
125	$(target).find('select.ess:visible').each(function(index) {
126		 if($(this).val() == '') {
127			 $(this).closest('.form-group').addClass('has-error');
128			error = 1;	
129		 } else {
130			 $(this).closest('.form-group').removeClass('has-error');
131		 }
132	});
133	
134	if (error == 0) {
135		return true;
136	} else {
137		alert ('Controleer de door u ingevoerde velden.');
138		return false;
139		//return true;
140	}
141}
142
143
144function valDate(input) {
145	//Valideer datum input, dd-mm-yyyy
146	var regs = input.split("-");
147	if (!regs[2]) {
148		return false;
149	}
150	if(regs[0] < 1 || regs[0] > 31) {
151		return false;
152	}
153	if(regs[1] < 1 || regs[1] > 12) {
154		return false;
155	}
156	if(regs[2] < 1800 || regs[2] > 2014) {
157		return false;
158	}
159	
160	return true;
161}
162
163function valMail(input) {
164	//Valideer email input
165	var atpos=input.indexOf("@");
166	var dotpos=input.lastIndexOf(".");
167	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=input.length) {
168	  return false;
169	}
170	return true;
171}
172
173

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.