# dealfront/trunk/admin/static/validator.js

Leadfeeder, version trunk. 35 lines.

- Page: https://pluginprobe.com/plugins/dealfront/trunk/code/admin/static/validator.js
- Raw: https://pluginprobe.com/plugins/dealfront/trunk/raw/admin/static/validator.js
- Modified: 2024-05-09T09:04:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/dealfront/trunk/code/admin/static/validator.js#L10-L20`.

```javascript
(function ($) {
  $(document).ready(function () {
    // alphanumeric regex
    var regex = /^(?=.*[a-zA-Z])(?=.*[0-9])[A-Za-z0-9]+$/;
    var errorMessage = 'The tracker ID entered by you doesn\'t look correct. Please enter the correct tracker ID to proceed.';

    $('#tracker-settings-form').on('submit', function (e) {
      var trackerId = $.trim($('#leadfeeder_tracker_id').val());

      if (trackerId === '') {
        return;
      }

      // strip v1 from tracker id if present
      if (trackerId.indexOf('v1') === 0) {
        trackerId = trackerId.split('_')[1];
      }

      // ensure 16 chars
      if (trackerId.length !== 16) {
        $('#dealfront-validation-errors').css('display', 'block');
        $('#dealfront-validation-errors #message-text').html(errorMessage);
        e.preventDefault();
      }

      // ensure alphanumeric
      if (!regex.test(trackerId)) {
        $('#dealfront-validation-errors').css('display', 'block');
        $('#dealfront-validation-errors #message-text').html(errorMessage)
        e.preventDefault();
      }
    });
  });
}(jQuery));

```
