PageSourceSearch

https://icosweb.net/wp/wp-content/plugins/swpm-form-builder/js/swpm-validation.js?ver=5.0.2

js icosweb.net collected 2026-09-24 09:56:56 UTC 3,011 bytes, 94 lines download raw bytes

1jQuery(document).ready(function ($) {
2	// !Validate each form on the page
3	$('.swpm-form-builder').each(function () {
4		$(this).validate({
5			rules: {
6				"swpm-secret": {
7					required: true,
8					digits: true,
9					maxlength: 2
10				},
11			},
12			errorClass: 'swpm-form-builder-error',
13			errorPlacement: function (error, element) {
14				if (element.is(':radio') || element.is(':checkbox'))
15					error.appendTo(element.parent().parent());
16				else if (element.is(':password'))
17					error.insertAfter(element);
18				else
19					error.insertAfter(element);
20			},
21			submitHandler: function (form) {
22				var invalid = false;
23				$('.swpm-checkbox-required').each(function () {
24					var multicheck = $(this);
25					if (multicheck.find('input:checked').length < 1) {
26						invalid = true;
27						if (multicheck.find('label.swpm-error').length === 0) {
28							$('<label generated="true" class="swpm-error">' + swpmFbValidation.str.checkOne + '</label>')
29								.appendTo(multicheck);
30						}
31					}
32				});
33				if (invalid) {
34					return false;
35				} else {
36					form.submit();
37					return true;
38				}
39			}
40		});
41	});
42
43	// Force bullets to hide, but only if list-style-type isn't set
44	$('.swpm-form-builder li:not(.swpm-item-instructions li, .swpm-span li)').filter(function () {
45		return $(this).css('list-style-type') !== 'none';
46	}).css('list-style', 'none');
47
48	// !Display jQuery UI date picker
49	$('.swpm-date-picker').each(function () {
50		var swpm_dateFormat = $(this).attr('data-dp-dateFormat') ? $(this).attr('data-dp-dateFormat') : 'mm/dd/yy';
51
52		$(this).datepicker({
53			dateFormat: swpm_dateFormat,
54			yearRange: "-100:+100",
55			changeMonth: true,
56			changeYear: true
57		});
58	});
59
60	// !Custom validation method
61	$.validator.addMethod('phone', function (value, element) {
62		// Strip out all spaces, periods, dashes, parentheses, and plus signs
63		value = value.replace(/[\+\s\(\)\.\-\ ]/g, '');
64
65                //More strict validation can be done in the PHP file.
66		return this.optional(element) || value.length > 5;
67
68	}, $.validator.messages.phone
69	);
70
71	// !Custom validation method
72	$.validator.addMethod('nowhitespace', function (value, element) {
73		// Strip out all spaces, periods, dashes, parentheses, and plus signs
74		return value.indexOf(" ") < 0 && value !== "";
75		;
76	}, $.validator.messages.nowhitespace
77	);
78	$.validator.addMethod('strongPass', function (value, element) {
79		return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).*$/g.test(value);
80	}, $.validator.messages.strongPassReq);
81	$.validator.addMethod('passmin8', function (value, element) {
82		return value.length >= 8;
83	}, $.validator.messages.minlength(8));
84	$.validator.addMethod('strongPass-edit', function (value, element) {
85		if (value.length === 0)
86			return true;
87		return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).*$/g.test(value);
88	}, $.validator.messages.strongPassReq);
89	$.validator.addMethod('passmin8-edit', function (value, element) {
90		if (value.length === 0)
91			return true;
92		return value.length >= 8;
93	}, $.validator.messages.minlength(8));
94});

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.