PageSourceSearch

https://oer2019.seab.gr/contactform/contactform.js

js seab.gr collected 2026-09-24 10:04:56 UTC 3,375 bytes, 118 lines download raw bytes

1jQuery(document).ready(function($) {
2  "use strict";
3
4  //Contact
5  $('form.contactForm').submit(function() {
6    var f = $(this).find('.form-group'),
7      ferror = false,
8      emailExp = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i;
9
10    f.children('input').each(function() { // run all inputs
11
12      var i = $(this); // current input
13      var rule = i.attr('data-rule');
14
15      if (rule !== undefined) {
16        var ierror = false; // error flag for current input
17        var pos = rule.indexOf(':', 0);
18        if (pos >= 0) {
19          var exp = rule.substr(pos + 1, rule.length);
20          rule = rule.substr(0, pos);
21        } else {
22          rule = rule.substr(pos + 1, rule.length);
23        }
24
25        switch (rule) {
26          case 'required':
27            if (i.val() === '') {
28              ferror = ierror = true;
29            }
30            break;
31
32          case 'minlen':
33            if (i.val().length < parseInt(exp)) {
34              ferror = ierror = true;
35            }
36            break;
37
38          case 'email':
39            if (!emailExp.test(i.val())) {
40              ferror = ierror = true;
41            }
42            break;
43
44          case 'checked':
45            if (! i.is(':checked')) {
46              ferror = ierror = true;
47            }
48            break;
49
50          case 'regexp':
51            exp = new RegExp(exp);
52            if (!exp.test(i.val())) {
53              ferror = ierror = true;
54            }
55            break;
56        }
57        i.next('.validation').html((ierror ? (i.attr('data-msg') !== undefined ? i.attr('data-msg') : 'wrong Input') : '')).show('blind');
58      }
59    });
60    f.children('textarea').each(function() { // run all inputs
61
62      var i = $(this); // current input
63      var rule = i.attr('data-rule');
64
65      if (rule !== undefined) {
66        var ierror = false; // error flag for current input
67        var pos = rule.indexOf(':', 0);
68        if (pos >= 0) {
69          var exp = rule.substr(pos + 1, rule.length);
70          rule = rule.substr(0, pos);
71        } else {
72          rule = rule.substr(pos + 1, rule.length);
73        }
74
75        switch (rule) {
76          case 'required':
77            if (i.val() === '') {
78              ferror = ierror = true;
79            }
80            break;
81
82          case 'minlen':
83            if (i.val().length < parseInt(exp)) {
84              ferror = ierror = true;
85            }
86            break;
87        }
88        i.next('.validation').html((ierror ? (i.attr('data-msg') != undefined ? i.attr('data-msg') : 'wrong Input') : '')).show('blind');
89      }
90    });
91    if (ferror) return false;
92    else var str = $(this).serialize();
93    var action = $(this).attr('action');
94    if( ! action ) {
95      action = 'contactform/contactform.php';
96    }
97    $.ajax({
98      type: "POST",
99      url: action,
100      data: str,
101      success: function(msg) {
102        // alert(msg);
103        if (msg == 'OK') {
104          $("#sendmessage").addClass("show");
105          $("#errormessage").removeClass("show");
106          $('.contactForm').find("input, textarea").val("");
107        } else {
108          $("#sendmessage").removeClass("show");
109          $("#errormessage").addClass("show");
110          $('#errormessage').html(msg);
111        }
112
113      }
114    });
115    return false;
116  });
117
118});

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.