1jQuery(document).ready(function ($) { 2 3// For Login PopUp Only 4 5 $('form#login').on('submit', function (e) { 6 if (!$(this).valid()) return false; 7 8 if ($(this).attr('id') == 'login') { 9 action = 'ajaxlogin'; 10 password = $('#password').val(); 11 email = $('#email').val(); 12 security = $('#loginsecurity').val(); 13 loginchk = $('#loginchk').val(); 14 current_page_url = $('#current_page_url').val(); 15 redirect_to_page = $('#redirect_to_page').val(); 16 } 17 18 ctrl = $(this); 19 20 var response = grecaptcha.getResponse(0); 21 var recaptcha_verification = (response.length == 0) ? "Invalid" : "Valid"; 22 23 showLoginLoadingAnimation(); 24 25 $.ajax({ 26 type: 'POST', 27 dataType: 'json', 28 url: ajax_auth_object.ajaxurl, 29 data: { 30 'action': action, 31 'password': password, 32 'email': email, 33 'security': security, 34 'loginchk': loginchk, 35 'recaptcha_verification': recaptcha_verification, 36 'redirect_to_page': redirect_to_page, 37 'current_page_url': current_page_url 38 }, 39 success: function (data) { 40 if (data.status == "emptyemail") { 41 $('p.emptyemail', ctrl).text(data.message); 42 } else if (data.status == "emptypassword") { 43 $('p.emptypassword', ctrl).text(data.message); 44 } else { 45 $('p.status', ctrl).text(data.message); 46 if (data.loggedin == true) { 47 window.location.href = data.redirect_me_to; 48 } else { 49 $('p.status', ctrl).text(data.message); 50 } 51 } 52 hideLoginLoadingAnimation(); 53 }, 54 error: function (error) { 55 console.error(error); 56 hideLoginLoadingAnimation(); 57 } 58 }); 59 e.preventDefault(); 60 }); 61 62 // Function to show loading animation for Login 63 function showLoginLoadingAnimation() { 64 $('.loading-overlay-login').show(); 65 } 66 67 // Function to hide loading animation for Login 68 function hideLoginLoadingAnimation() { 69 $('.loading-overlay-login').hide(); 70 } 71 72// For Signup Popup 73 74 $('form#register').validate({ 75 rules: { 76 phone_number: { 77 required: true, 78 minlength: 10, 79 maxlength: 15 80 }, 81 user_password: { 82 required: true, 83 minlength: 6, 84 maxlength: 20 85 }, 86 confirm_password: { 87 required: true, 88 equalTo: '#user_password' 89 }, 90 first_name: { 91 required: true, 92 lettersOnly: true // Custom rule for letters only 93 }, 94 last_name: { 95 required: true, 96 lettersOnly: true // Custom rule for letters only 97 }, 98 }, 99 messages: { 100 phone_number: { 101 required: 'Please enter your phone number', 102 minlength: 'Phone number must be at least 10 digits long', 103 maxlength: 'Phone number must not exceed 15 digits' 104 }, 105 user_password: { 106 required: 'Please enter a password', 107 minlength: 'Password must be at least 6 characters long', 108 maxlength: 'Password must not exceed 20 characters' 109 }, 110 confirm_password: { 111 required: 'Please confirm your password', 112 equalTo: 'Passwords do not match' 113 }, 114 first_name: { 115 required: 'Please enter your first name', 116 lettersOnly: 'Only letters are allowed in the first name' 117 }, 118 last_name: { 119 required: 'Please enter your last name', 120 lettersOnly: 'Only letters are allowed in the last name' 121 }, 122 }, 123 submitHandler: function (form) { 124 // Your existing submit handler code 125 var action, first_name, last_name, user_password, confirm_password, email_address, phone_number, security, signupchk, current_page_url, redirect_to_page; 126 var signup_response = grecaptcha.getResponse(1); 127 var signup_recaptcha_verification = (signup_response.length == 0) ? "Invalid" : "Valid"; 128 129 if ($(form).attr('id') == 'register') { 130 action = 'ajaxregister'; 131 first_name = $('#first_name').val(); 132 last_name = $('#last_name').val(); 133 user_password = $('#user_password').val(); 134 confirm_password = $('#confirm_password').val(); 135 email_address = $('#email_address').val(); 136 phone_number = $('#phone_number').val(); 137 security = $('#signonsecurity').val(); 138 signupchk = $('#signupchk').val(); 139 current_page_url = $('#current_page_url').val(); 140 redirect_to_page = $('#redirect_to_page').val(); 141 } 142 143 ctrl = $(form); 144 145 showSignupLoadingAnimation(); 146 147 $.ajax({ 148 type: 'POST', 149 dataType: 'json', 150 url: ajax_auth_object.ajaxurl, 151 data: { 152 'action': action, 153 'first_name': first_name, 154 'last_name': last_name, 155 'email_address': email_address, 156 'phone_number': phone_number, 157 'user_password': user_password, 158 'confirm_password': confirm_password, 159 'security': security, 160 'signupchk': signupchk, 161 'signup_recaptcha_verification': signup_recaptcha_verification, 162 'current_page_url': current_page_url, 163 'redirect_to_page': redirect_to_page 164 }, 165 success: function (data) { 166 console.log(data); 167 $('p.status', ctrl).text(data.message); 168 if (data.loggedin == true) { 169 window.location.href = data.redirect_me_to; 170 } else { 171 $('p.status', ctrl).text(data.message); 172 } 173 hideSignupLoadingAnimation(); 174 }, 175 error: function (error) { 176 console.error(error); 177 hideSignupLoadingAnimation(); 178 } 179 }); 180 } 181 }); 182 183 // Add custom method for letters only
184 $.validator.addMethod("lettersOnly", function (value, element) { 185 return this.optional(element) || /^[a-zA-Z\s]+$/.test(value); 186 }, "Only letters are allowed."); 187 188 // Function to show loading animation for Signup 189 function showSignupLoadingAnimation() { 190 $('.loading-overlay-signup').show(); 191 } 192 193 // Function to hide loading animation for Signup 194 function hideSignupLoadingAnimation() { 195 $('.loading-overlay-signup').hide(); 196 } 197 198 199 //Global_Login form 200 201 $('form#loginp').on('submit', function (e) { 202 203 204 if (!$(this).valid()) return false; 205 206 if ($(this).attr('id') == 'loginp') { 207 action = 'ajaxloginp'; 208 password = $('#password').val(); 209 email = $('#email').val(); 210 security = $('#loginsecurity').val(); 211 loginchk = $('#loginchk').val(); 212 // current_page_url = $('#current_page_url').val(); 213 // redirect_to_page = $('#redirect_to_page').val(); 214 } 215 216 ctrl = $(this); 217 218 var response = grecaptcha.getResponse(0); 219 var recaptcha_verification = (response.length == 0) ? "Invalid" : "Valid"; 220 221 showLoginLoadingAnimation(); 222 223 $.ajax({ 224 type: 'POST', 225 dataType: 'json', 226 url: ajax_auth_object.ajaxurl, 227 data: { 228 'action': action, 229 'password': password, 230 'email': email, 231 'security': security, 232 'loginchk': loginchk, 233 'recaptcha_verification': recaptcha_verification, 234 // 'redirect_to_page': redirect_to_page, 235 // 'current_page_url': current_page_url 236 }, 237 success: function (data) { 238 239 console.log(data); 240 // if (data.status == "emptyemail") { 241 // $('p.emptyemail', ctrl).text(data.message); 242 // } else if (data.status == "emptypassword") { 243 // $('p.emptypassword', ctrl).text(data.message); 244 // } else { 245 // $('p.status', ctrl).text(data.message); 246 // if (data.loggedin == true) { 247 // window.location.href = data.redirect_me_to; 248 // } else { 249 // $('p.status', ctrl).text(data.message); 250 // } 251 // } 252 hideLoginLoadingAnimation(); 253 }, 254 error: function (error) { 255 console.error(error); 256 hideLoginLoadingAnimation(); 257 } 258 }); 259 e.preventDefault(); 260 }); 261 262 263});
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.