PageSourceSearch

https://simputer.org/static/js/contact_form.js

js simputer.org collected 2026-10-02 13:14:06 UTC 3,755 bytes, 91 lines download raw bytes

1$(document).ready(function () {
2
3  String.prototype.isEmail = function() {
4    // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
5    return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(this);
6  };
7
8  $("#contact-form").submit(function(event){
9    event.stopPropagation();
10    var path = window.location.pathname;
11    path = path.split('/')[path.split('/').length-1].split('.phtml')[0];
12    path = path.toLowerCase().replace(/\b[a-z]/g, function(letter) {
13            return letter.toUpperCase();});
14    var name = $("#name").val();
15    var email = $("#email").val();
16    var phone = $("#phone").val();
17    var ph_reqd = $("#phone").data('phone');
18    var designation = $("#designation").val();
19    var organization = $("#institute").val();
20
21    var all_valid = true;
22    var message = "Oops! Something went wrong. Please try again!";
23
24    var mandatory = [name, email, organization];
25    if(ph_reqd)    mandatory.push(phone);
26    $.each(mandatory, function(k, v){
27      if (v == ""){
28        message = "Mandatory fields cannot be left blank";
29        all_valid = false;
30        return false;
31      }
32    });
33    if (all_valid == true){
34      $.each([email, phone], function(k, v){
35        if(k == 0){
36          if (!v.isEmail()){
37            message = "Invalid email";
38            all_valid = false;
39            return false;
40          }
41        }
42        if(k == 1){
43          if (v.length > 0 && v.length < 10){
44            if (isNaN(v)){
45              message = "Invalid phone number";
46              all_valid = false;
47              return false;
48            }
49            message = "Invalid phone number";
50            all_valid = false;
51            return false;
52          }
53        }
54      });
55    }
56    else {
57      event.preventDefault();
58      $("#response").html(message).css('color','red').show();
59      $('html, body').animate({
60        scrollTop: $("#response").offset().top - 80
61      }, 500);
62    }
63    if (all_valid == true){
64      var form_data = {"category":path,"name":name,"email":email,"phone":phone,"designation":designation,"organization":organization};
65      event.preventDefault();
66      $.ajax({
67               url: "api/contact.php",
68               type: 'post',
69               data: form_data,
70               async: false,
71               dataType: "json",
72               success: function(resp) {
73                   //alert(resp.message);
74                   $("#response").html(resp.message).css('color','#1414ff').show();
75                   $('html, body').animate({
76                     scrollTop: $("#response").offset().top - 80
77                   }, 500);
78              }
79      });
80    }
81    else {
82      event.preventDefault();
83      $("#response").html(message).css('color','red').show();
84      $('html, body').animate({
85        scrollTop: $("#response").offset().top - 80
86      }, 500);
87
88    }
89 });
90});
91

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.