1(function ($) { 2 $(document).ready(function () { 3 var emailValid = false; 4 var userValid = false; 5 var passwordsMatch = true; 6 7 var email = $("#email_address"); 8 var username = $("#username"); 9 var passwordField = $("#password"); 10 var passwordConfirmField = $("#confirm_password"); 11 12 passwordField.focus(function () { 13 passwordsMatch = false; 14 $(".password-error").remove(); 15 16 setSubmitBtnActive(); 17 }); 18 19 passwordConfirmField.focus(function () { 20 passwordsMatch = false; 21 $(".password-error").remove(); 22 23 setSubmitBtnActive(); 24 }); 25 26 passwordField.blur(function () { 27 passwordsMatch = validatePasswords(); 28 setSubmitBtnActive(); 29 }); 30 31 passwordConfirmField.blur(function () { 32 passwordsMatch = validatePasswords(); 33 setSubmitBtnActive(); 34 }); 35 36 email.focus(function () { 37 emailValid = false; 38 $(".email-error").remove(); 39 40 setSubmitBtnActive(); 41 }); 42 43 email.blur(function () { 44 var data = { 45 action: "leaky_paywall_validate_registration", 46 email: email.val(), 47 nonce: leaky_paywall_validate_ajax.register_nonce 48 }; 49 50 $.post(leaky_paywall_validate_ajax.ajaxurl, data, function (resp) { 51 if (resp.status == "error") { 52 $( 53 '<p class="leaky-paywall-input-error email-error">' + 54 resp.message + 55 "</p>" 56 ).insertAfter("#email_address"); 57 emailValid = false; 58 } else { 59 emailValid = true; 60 } 61 62 setSubmitBtnActive(); 63 }); 64 }); 65 66 if (username.length > 0) { 67 // username 68 username.focus(function () { 69 userValid = false; 70 $(".username-error").remove(); 71 72 setSubmitBtnActive(); 73 }); 74 75 username.blur(function () { 76 var data = { 77 action: "leaky_paywall_validate_registration", 78 username: username.val(), 79 nonce: leaky_paywall_validate_ajax.register_nonce 80 }; 81 82 $.post(leaky_paywall_validate_ajax.ajaxurl, data, function (resp) { 83 if (resp.status == "error") { 84 $( 85 '<p class="leaky-paywall-input-error username-error">' + 86 resp.message + 87 "</p>" 88 ).insertAfter("#username"); 89 userValid = false; 90 } else { 91 userValid = true; 92 } 93 setSubmitBtnActive(); 94 }); 95 }); 96 } else { 97 // email is the username 98 userValid = true; 99 } 100 101 function validatePasswords() { 102 var pwMatch = 103 !passwordField.val() || 104 !passwordConfirmField.val() || 105 passwordField.val() === passwordConfirmField.val(); 106 passwordsMatch = pwMatch; 107 if (pwMatch) { 108 $(".password-error").remove(); 109 } else { 110 if (passwordField.val() && passwordConfirmField.val()) { 111 $( 112 '<p class="leaky-paywall-input-error password-error">' + 113 leaky_paywall_validate_ajax.password_text + 114 "</p>" 115 ).insertAfter(passwordConfirmField); 116 } 117 } 118 return pwMatch; 119 } 120 121 function setSubmitBtnActive() { 122 if (userValid && emailValid && passwordsMatch) { 123 $("#leaky-paywall-submit").prop("disabled", false); 124 $("#leaky-paywall-registration-next").prop("disabled", false); 125 } else { 126 // $("#leaky-paywall-submit").prop("disabled", true); 127 // $("#leaky-paywall-registration-next").prop("disabled", true); 128 } 129 } 130 }); 131})(jQuery);
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.