PageSourceSearch

https://www.k12dive.com/static/js/dive_mailcheck.js?520919230926

js k12dive.com collected 2026-09-24 08:36:44 UTC 1,820 bytes, 62 lines download raw bytes

1/**
2 *  Adds mailcheck to all inputs with type=email inside forms with class "js-form-email-validate".
3 *
4 *  This assumes mailcheck.min.js and jquery have been included.
5 **/
6
7
8/**
9 * Call mailcheck and handle the response by clearing all previous mail check
10 * message, and printing a new message if needed.
11 *
12 * @param {object} textfield the email input field we're processing
13 * @returns {null} nothing
14 */
15function checkEmailAndRespond(textfield) {
16  $(textfield).mailcheck({
17    suggested: function(element, suggestion) {
18      /**
19       * suggestion is in the form
20       *   {
21       *     address: 'test',          // the address; part before the @ sign
22       *     domain: 'gmail.com',    // the suggested domain
23       *     full: '[email protected]'  // the full suggested email
24       *   }
25       */
26
27      // remove old instances of the warning - anywhere on the page
28      $('.js-email-check').remove();
29
30      var $emailfield = $(element);
31      var textToAdd = window.interpolate(
32        window.gettext('Did you mean %(suggestedDomain)s?'),
33        { suggestedDomain: `<b>${suggestion.domain}</b>` },
34        true
35      );
36      var htmlToAdd = `<p class="email-check js-email-check">${textToAdd}</p>`;
37
38      // we want to put the message outside any label or div the field is in
39      if ($emailfield.parentsUntil('form').length) {
40        $($emailfield.parent()).after(htmlToAdd);
41      } else {
42        $emailfield.after(htmlToAdd);
43      }
44    },
45    empty: function(element) {
46      $('.js-email-check').remove();
47    },
48  });
49}
50
51$(document).ready(function() {
52  /**
53   * Apply our handler to each relevant input field on the page.
54   */
55  $('.js-form-email-validate input[type=email]').each(function() {
56    $(this).on('blur', function() {
57      checkEmailAndRespond(this);
58    });
59  });
60});
61
62

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.