1/* 2 * Let's begin with validation functions 3 */ 4jQuery.extend(jQuery.fn, { 5 /* 6 * check if field value lenth more than 3 symbols ( for name and comment ) 7 */ 8 validate: function () { 9 if (jQuery(this).val().length < 3) { 10 jQuery(this).addClass('error'); 11 return false 12 } else { 13 jQuery(this).removeClass('error'); 14 return true 15 } 16 }, 17 /* 18 * check if email is correct 19 * add to your CSS the styles of .error field, for example border-color:red; 20 */ 21 validateEmail: function () { 22 var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/, 23 emailToValidate = jQuery(this).val(); 24 if (!emailReg.test(emailToValidate) || emailToValidate == "") { 25 jQuery(this).addClass('error'); 26 return false 27 } else { 28 jQuery(this).removeClass('error'); 29 return true 30 } 31 }, 32}); 33 34jQuery(function ($) { 35 36 /* 37 * On comment form submit 38 */ 39 var form = $('#commentform'); 40 form.submit(function (e) { 41 var button = $('.comments-form-btn'); 42 43 if ($('#author').length) 44 $('#author').validate(); 45 46 if ($('#email').length) 47 $('#email').validateEmail(); 48 49 $('#comment').validate(); 50 51 if (!button.hasClass('loadingform') && !$('#author').hasClass('error') && !$('#email').hasClass('error') && !$('#comment').hasClass('error')) { 52 53 $.ajax({ 54 type: 'POST', 55 url: changelly_ajax_comment_params.ajaxurl, 56 data: $(this).serialize() + '&action=ajaxcomments', 57 beforeSend: function (xhr) { 58 button.addClass('loadingform'); 59 }, 60 error: function (request, status, error) { 61 form.append('<p class="comment-status comment-error" >' + error + '</p>'); 62 }, 63 success: function (addedCommentHTML) { 64 if(!$('.comment-error').length){ 65 form.append('<p class="comment-status comment-success" >' + addedCommentHTML + '</p>'); 66 } 67 $('#comment').val(''); 68 $('#author').val(''); 69 $('#email').val(''); 70 form.removeClass('is-open'); 71 }, 72 complete: function () { 73 button.removeClass( 'loadingform' ); 74 } 75 }); 76 } 77 return false; 78 }); 79});
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.