PluginProbe
Leadfeeder / trunk
Leadfeeder vtrunk
1.3.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0
dealfront / admin / static / validator.js

validator.js in Leadfeeder trunk, at admin/static/validator.js

35 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 $(document).ready(function () {
3 // alphanumeric regex
4 var regex = /^(?=.*[a-zA-Z])(?=.*[0-9])[A-Za-z0-9]+$/;
5 var errorMessage = 'The tracker ID entered by you doesn\'t look correct. Please enter the correct tracker ID to proceed.';
6
7 $('#tracker-settings-form').on('submit', function (e) {
8 var trackerId = $.trim($('#leadfeeder_tracker_id').val());
9
10 if (trackerId === '') {
11 return;
12 }
13
14 // strip v1 from tracker id if present
15 if (trackerId.indexOf('v1') === 0) {
16 trackerId = trackerId.split('_')[1];
17 }
18
19 // ensure 16 chars
20 if (trackerId.length !== 16) {
21 $('#dealfront-validation-errors').css('display', 'block');
22 $('#dealfront-validation-errors #message-text').html(errorMessage);
23 e.preventDefault();
24 }
25
26 // ensure alphanumeric
27 if (!regex.test(trackerId)) {
28 $('#dealfront-validation-errors').css('display', 'block');
29 $('#dealfront-validation-errors #message-text').html(errorMessage)
30 e.preventDefault();
31 }
32 });
33 });
34 }(jQuery));
35