PageSourceSearch

https://www.htmlpanda.com/assets-new/js/service_form_validation.js

js htmlpanda.com collected 2026-10-02 18:08:12 UTC 5,895 bytes, 181 lines download raw bytes

1function validateNameService() {
2  var e = $("#name").val();
3  return "" !== e && /^[A-Za-z.'"!`@$^%*,`~#&-\s]+$/.test(e)
4    ? ($("#tooltip_name_service").css("display", "none"), !0)
5    : ($("#tooltip_name_service").css("display", "inline-block"), !1);
6}
7function validateEmailAddressService() {
8  var e = $("#email").val();
9  return "" !== e &&
10    /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,20}|[0-9]{1,20})(\]?)$/.test(
11      e
12    )
13    ? ($("#tooltip_email_service").css("display", "none"), !0)
14    : ($("#tooltip_email_service").css("display", "inline-block"), !1);
15}
16function validatePhoneNumberService() {
17  var e = $("#phone").val();
18  return "" === e
19    ? ($("#tooltip_phone_service").css("display", "none"), !0)
20    : "" !== e && /^[A-Za-z+()\/\-.\d\s]+$/.test(e)
21    ? ($("#tooltip_phone_service").css("display", "none"), !0)
22    : ($("#tooltip_phone_service").css("display", "inline-block"), !1);
23}
24function validateCommentService() {
25  return "" !== $("#message").val()
26    ? ($("#tooltip_message_service").css("display", "none"), !0)
27    : ($("#tooltip_message_service").css("display", "inline-block"), !1);
28}
29function aiResponseService() {
30  if (
31    $("#work_with_us #previousMessage").val() &&
32    $("#work_with_us #messg_form_popup").val().trim() ===
33      $("#work_with_us #previousMessage").val().trim()
34  ) {
35    $("#work_with_us #tooltip_message_popup")
36      .html("Please describe your requirements in detail.")
37      .show();
38    return Promise.resolve(false);
39  }
40
41  // If leadType is already set, return success immediately
42  if (
43    $("#work_with_us #leadType").val() &&
44    $("#work_with_us #leadType").val() == "INCOMPLETE" &&
45    $("#work_with_us #incompleteLeadCount").val() == 1
46  ) {
47    //
48  } else if ($("#work_with_us #leadType").val()) {
49    return Promise.resolve(true);
50  }
51
52  if (
53    $("#work_with_us #leadType").val() &&
54    $("#work_with_us #leadType").val() == "INCOMPLETE"
55  ) {
56    if ($("#work_with_us #incompleteLeadCount").val() > 1) {
57      $("#work_with_us #incompleteLeadCount").val(
58        parseInt($("#work_with_us #incompleteLeadCount").val()) + 1
59      );
60    }
61  }
62
63  // Validate required fields before making API call
64  if (
65    !(
66      validateNameService() &
67      validateEmailAddressService() &
68      validatePhoneNumberService() &
69      validateCommentService()
70    )
71  ) {
72    return Promise.resolve(false);
73  }
74
75  return new Promise((resolve) => {
76    $.ajax({
77      url: "pass.php",
78      type: "get",
79      data: {
80        action: "aiResponse",
81        message: $("#work_with_us #messg_form_popup").val(),
82      },
83      success: function (response) {
84        try {
85          let res = JSON.parse(response);
86
87          $("#work_with_us").append(
88            '<input type="hidden" name="leadType" id="leadType" value="' +
89              res.LeadType +
90              '">'
91          );
92
93          $("#work_with_us").append(
94            '<input type="hidden" name="score" id="score" value="' +
95              res.Score +
96              '">'
97          );
98          $("#work_with_us").append(
99            '<input type="hidden" name="quality" id="quality" value="' +
100              res.Quality +
101              '">'
102          );
103
104          $("#work_with_us").append(
105            '<input type="hidden" name="aiBody" id="aiBody" value="' +
106              res.AIDATA +
107              '">'
108          );
109
110          if (res.LeadType === "INCOMPLETE") {
111            $("#work_with_us").append(
112              '<input type="hidden" id="previousMessage" name="previousMessage" value="' +
113                $("#work_with_us #messg_form_popup").val() +
114                '">'
115            );
116            if ($("#work_with_us #incompleteLeadCount").length > 0) {
117              $("#work_with_us #incompleteLeadCount").val(
118                parseInt($("#work_with_us #incompleteLeadCount").val()) + 1
119              );
120            } else {
121              $("#work_with_us").append(
122                '<input type="hidden" id="incompleteLeadCount" name="incompleteLeadCount" value="1">'
123              );
124            }
125
126            $("#work_with_us #tooltip_message_popup")
127              .html("Please describe your requirements in detail.")
128              .show();
129          } else {
130            $("#work_with_us").append(
131              '<input type="hidden" id="incompleteLeadCount" name="incompleteLeadCount" value="
1310">'
132            );
133            $("#work_with_us #tooltip_message_popup").hide();
134          }
135
136          resolve(res);
137        } catch (e) {
138          console.error("Error parsing AI response:", e);
139          $("#work_with_us #tooltip_message_popup").hide();
140          resolve(true);
141        }
142      },
143      error: function (xhr, status, error) {
144        console.error("Error in AI Response API:", error);
145        $("#work_with_us #tooltip_message_popup").hide();
146        resolve(true);
147      },
148    });
149  });
150}
151$(document).ready(function () {
152  $("#name,#email,#phone,#message").on("focus", function () {
153    var e = $(this).attr("id");
154    $("#tooltip_" + e + "_service").css("display", "none");
155  }),
156    $("#service_btn_form").click(async function (e) {
157      e.preventDefault();
158      const aiResult = await aiResponseService();
159      if (!aiResult) {
160        return false;
161      }
162      var incompleteCount = $("#work_with_us #incompleteLeadCount").val();
163      // Check for incomplete lead type
164      if (
165        typeof aiResult === "object" &&
166        aiResult.LeadType === "INCOMPLETE" &&
167        incompleteCount == 1
168      ) {
169        return false;
170      }
171
172      return validateNameService() &
173        validateEmailAddressService() &
174        validatePhoneNumberService() &
175        validateCommentService()
176        ? ($("#work_with_us").submit(),
177          $("#service_btn_form").html("PLEASE WAIT..."),
178          !0)
179        : ($("#service_btn_form").html("CONNECT WITH US"), !1);
180    });
181});

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.