1/// <reference path="LiveFormValidation.js" /> 2function validatenumerics(key) { 3 //getting key code of pressed key 4 var keycode = (key.which) ? key.which : key.keyCode; 5 //comparing pressed keycodes 6 7 if (keycode > 31 && (keycode < 48 || keycode > 57)) { 8 return false; 9 } 10 else return true; 11}; 12 13//$.validator.messages.wordcount = 'Please enter no more than {0} words'; 14//$.validator.messages.alphanumeric = 'This field can only contain letters and numbers'; 15$.validator.addMethod("vmaxlength", $.validator.methods.maxlength, LFValidations.vmaxlength); 16$.validator.addMethod('rbrequired', function (value, element) { 17 if ($(element).closest('.Field.Radiobutton').find("input:checked").length == 1 && $(element).closest('.Field.Radiobutton').find("input:checked").val() == "&%&" && $(element).closest('.Field.Radiobutton').find('input[type=hidden]').val() == "") { 18 return false; 19 } 20 else 21 return true; 22}, LFValidations.required); 23$.validator.addMethod('cbrequired', function (value, element) { 24 if ($(element).closest('.Field.Checkbox').find("input:checked").length == 1 && $(element).closest('.Field.Checkbox').find("input:checked").val() == "&%&" && $(element).closest('.Field.Checkbox').find('input[type=hidden]').val() == "") { 25 return false; 26 } 27 else if ($(element).closest('.Field.Checkbox').find("input:checked").length < 1) 28 return false; 29 else 30 return true; 31}, LFValidations.cbrequired); 32 33$.validator.addMethod('matrixCbrequired', function (value, element) { 34 if ($(element).closest('tr').find("input:checked").length < 1) 35 return false; 36 else 37 return true; 38}, LFValidations.required); 39 40$.validator.addMethod('matrixddlrequired', function (value, element) { 41 if ($(element).find('option:selected').index() == 0) 42 return false; 43 else 44 return true; 45}, LFValidations.required); 46 47$.validator.addMethod('checkCaptcha', function (value, element) { 48 if ($(element).closest('.Field.Checkbox').find("input:checked").length < 1) 49 return false; 50 else 51 return true; 52}, LFValidations.cbrequired); 53 54$.validator.addMethod('wordcount', function (value, element) { 55 var wordCount = $(element).attr('wordcount'); 56 if ($(element).val().split(" ").length > wordCount) 57 return false; 58 else 59 return true; 60}, LFValidations.wordcount); 61 62$.validator.addMethod('alphanumeric', function (value, element) { 63 var ele = $(element).val(); 64 if (ele != "") { 65 var re = /^[a-zA-Z0-9]+$/; 66 if (re.test(ele)) 67 return true; 68 else 69 return false; 70 } 71 else 72 return true; 73}, LFValidations.alphanumeric); 74 75$.validator.addMethod('alphabetic', function (value, element) { 76 var ele = $(element).val(); 77 if (ele != "") { 78 var re = /^[a-zA-Zs]+$/; 79 if (re.test(ele)) 80 return true; 81 else 82 return false; 83 } 84 else 85 return true; 86}, LFValidations.alphabetic); 87 88$.validator.addMethod('numeric', function (value, element) { 89 var ele = $(element).val(); 90 if (ele != "") { 91 var re = new RegExp("^[0-9]{" + ele.length + "}$"); 92 if (re.test(ele)) 93 return true; 94 else 95 return false; 96 } 97 else 98 return true; 99}, LFValidations.numeric); 100 101$.validator.addMethod('custom', function (value, element) { 102 if ($(element).parent().children('.customsetting').html() != "") { 103 var re = new RegExp($(element).parent().children('.customsetting').html()); 104 if (re.test(value)) 105 return true; 106 else 107 return false; 108 } 109 else 110 return true; 111}, LFValidations.custom); 112 113 114$.validator.addMethod('scorerequired', function (value, element) { 115 if ($(element).parent().find('div input[type=hidden]').val() == "") 116 return false; 117 else 118 return true; 119}, LFValidations.scorerequired); 120 121$.validator.addMethod('scalerequired', function (value, element) { 122 if ($(element).parent().parent().find('input[type=radio]').is(":checked") == true) 123 return true; 124 else 125 return false; 126}, LFValidations.scalerequired); 127 128$.validator.addMethod('isvaliddate', function (value, element) { 129 var month, day, year, hour, minute; 130 if ($(element).val() != "") { 131 $($(element).parent().parent().find('span.Field-SubLabel-TextBox')).each(function (index, item) { 132 if ($(item).find('input').length != 0) { 133 if ($(item).find('input').attr('class').indexOf("datepicker_month") != -1)
134 month = $(item).find('input').val(); 135 else if ($(item).find('input').attr('class').indexOf("datepicker_day") != -1) 136 day = $(item).find('input').val(); 137 else if ($(item).find('input').attr('class').indexOf("datepicker_year") != -1) 138 year = $(item).find('input').val(); 139 } 140 if ($(item).find('select').length != 0) { 141 if ($(item).find('select').attr('class').indexOf("datepicker_month") != -1) 142 month = $(item).find('select').val(); 143 if (month == "0") 144 month = ""; 145 if ($(item).find('select').attr('class').indexOf("datepicker_hour") != -1) 146 hour = $(item).find('select').val(); 147 else if ($(item).find('select').attr('class').indexOf("datepicker_minute") != -1) 148 minute = $(item).find('select').val(); 149 } 150 }); 151 if (month == undefined) 152 month = ""; 153 if (day == undefined) 154 day = ""; 155 if (year == undefined) 156 year = ""; 157 if (hour == undefined) 158 hour = ""; 159 if (minute == undefined) 160 minute = ""; 161 if (month != "" && day != "" && year != "" && hour != "" && minute != "") { 162 var dt = new Date(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), parseInt(hour, 10), parseInt(minute, 10), 00, 00); 163 if (dt.getDate() != parseInt(day, 10) || dt.getMonth() != (parseInt(month, 10) - 1) || dt.getFullYear() != parseInt(year, 10)) { 164 return false; 165 } 166 else 167 return true; 168 } 169 else if (month != "" && day != "" && year != "" && hour == "" && minute == "") { 170 var dt = new Date(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10), 00, 00, 00, 00); 171 if (dt.getDate() != parseInt(day, 10) || dt.getMonth() != (parseInt(month, 10) - 1) || dt.getFullYear() != parseInt(year, 10)) { 172 return false; 173 } 174 else 175 return true; 176 } 177 else if (month == "" && (day != "" || year != "")) 178 return false; 179 else if (day == "" && (month != "" || year != "")) 180 return false; 181 else if (year == "" && (day != "" || month != "")) 182 return false; 183 else if (year == "" && day == "" && month == "" && (hour != "" || minute != "")) 184 return false; 185 else if (year != "" && day != "" && month != "" && (hour == "" || minute == "")) 186 return false; 187 else 188 return true; 189 } 190 else 191 return true; 192}, LFValidations.isvaliddate); 193 194$.validator.addMethod('furequired', function (value, element) { 195 if ($(element).parent().find('.plupload_content').length == 0) 196 return true; 197 if ($(element).parent().find('.plupload_content').attr('controlid').length > 0) { 198 var object = $(element).parent().find('.plupload_content').attr('controlid') + ".files.length==0"; 199 var resume = true; 200 if ($(element).parent().find('.fileresume').length > 0) { 201 var val = $("#" + $(element).parent().find('.fileresume').attr('id')).val(); 202 if (val !== null && val.trim() !== '') { 203 resume = false; 204 } 205 } 206 207 if (eval(object) && resume) 208 return false; 209 else 210 return true; 211 } 212 else 213 return true; 214}, LFValidations.furequired); 215 216$.validator.addMethod('fbrequired', function (value, element) { 217 var ele = $(element).val(); 218 if (ele) { 219 return true; 220 } 221 else 222 return false; 223}, LFValidations.fbrequired); 224 225$(document).ready(function () { 226 227 $(".Field.Phone input[type=text].phone").each(function (index) { 228 if (typeof $(this).attr("placeholder") != 'undefined') 229 $("#" + $(this).attr("id")).mask($(this).attr("placeholder"), { clearIfNotMatch: true });
230 }); 231 232 $(".Field.Textbox input[type=text].mask").each(function (index) { 233 if (typeof $(this).attr("placeholder") != 'undefined') 234 $("#" + $(this).attr("id")).mask($(this).attr("placeholder"), { clearIfNotMatch: true }); 235 }); 236 237 $(".Field.Password .strength").each(function (index) { 238 var options = {}; 239 options.ui = { 240 container: "#" + $(this).attr("id"), 241 showVerdictsInsideProgressBar: true, 242 progressBarEmptyPercentage: 0, 243 progressBarMinPercentage: 25, 244 viewports: { 245 progress: "#" + $(this).attr("id") + "_viewport_progress" 246 } 247 }; 248 $("#" + $(this).attr("id") + '_Password').pwstrength(options); 249 $("#" + $(this).attr("id") + '_Password').pwstrength("addRule", "testRule" + index, function (options, word, score) { 250 return word.match(/[0-9]/) && score; 251 }, 5, true); 252 }); 253 254 $('.Field.Required.Fileupload input').attr("furequired", "furequired"); 255 $(".Field.Required.Fileupload input.fileresume").removeAttr('furequired'); 256 257 $('.Field.CkEditor.Required div.Field-Container-Wide').attr("editorrequired", "true"); 258 $('.Field.CkEditor.Required div.Field-Container').attr("editorrequired", "true"); 259 260 $(".Field.CkEditor").each(function (index) { 261 if (typeof $(this).attr("guid") != 'undefined') { 262 var GUID = $(this).attr("guid").replace(/-/g, ''); 263 $(this).addClass('ck' + GUID.toLowerCase() + 'ck'); 264 } 265 }); 266 267 //Do Not Validate Required on Hidden Fields such as Allow Other in Radiobutton/Checkboxes 268 $('.Field input[type=hidden]').addClass("nrequired"); 269 270 //Validate Required on All Inputs, Textareas & Selects Except Checkbox and those that explictly have "nrequired" class 271 $(".Field.Required:not(.Checkbox) input:not(.nrequired),.Field.Required select,.Field.Required textarea").attr("required", ""); 272 273 //Validate Required on Radiobutton other fieds validate 274 $(".Field.Required.Radiobutton input[type=radio]:not(.nrequired)").attr("rbrequired", "rbrequired"); 275 276 //Validate Required on Checkbox 277 $(".Field.Required.Checkbox input[type=checkbox]:not(.nrequired)").attr("cbrequired", "cbrequired"); 278 279 //Validate Required on matrix checkbox 280 $(".Field.Required.Matrix input[type=checkbox]").removeAttr('required'); 281 $(".Field.Required.Matrix input[type=checkbox]").attr("matrixCbrequired", "matrixCbrequired"); 282 283 //Validate Required on matrix dropdownlist 284 $(".Field.Required.Matrix select").removeAttr('required'); 285 $(".Field.Required.Matrix select").attr("matrixddlrequired", "matrixddlrequired"); 286 287 //Validate Email 288 $(".Field.Email input[type=text]").attr("email", "email"); 289 290 //Validate Cutom in Email field 291 $(".Field.Email.Custom input[type=text]").removeAttr('email'); 292 $(".Field.Email.Custom input[type=text]").attr("custom", "custom"); 293 294 //Validate CreditCard 295 $(".Field.CreditCard input[type=text].CardNumber").attr("creditcard", "creditcard"); 296 297 //Validate Alphanumeric 298 $(".Field.AlphaNumeric input[type=text]").attr("alphanumeric", "alphanumeric"); 299 300 //Validate Custom 301 $(".Field.Textbox.Custom input[type=text]").attr("custom", "custom"); 302 $(".Field.Textarea.Custom textarea").attr("custom", "custom"); 303 304 //Validate Alphabetic 305 $(".Field.Alphabetic input[type=text]").attr("alphabetic", "alphabetic"); 306 307 //Validate Numeric 308 $(".Field.Numeric input[type=text]").attr("numeric", "numeric"); 309 $(".Field.CreditCard input[type=text].CVV").attr("numeric", "numeric"); 310 311 // Validate Datetime 312 $(".Field.Datetime input[type=text]").attr("isvaliddate", "isvaliddate"); 313 $(".Field.Datetime select").attr("isvaliddate", "isvaliddate"); 314 315 // Validate BirthDate 316 $(".Field.Birthdate input[type=text]").attr("isvaliddate", "isvaliddate"); 317 $(".Field.Birthdate select").attr("isvaliddate", "isvaliddate"); 318 319 //Validate StarRating 320 $(".Field.Required.StarRating input[type=hidden].starratinghidden").removeClass('nrequired').attr("scorerequired", "scorerequired"); 321 322 //Validate ScaleRating 323 $(".Field.Required.ScaleRating input[type=hidden]").attr("scalerequired", "scalerequired"); 324 $(".Field.Required.ScaleRating input[type=radio]").removeAttr('required'); 325 326 $(".Field.BrowseFile.Required input[required=required]").removeAttr('required'); 327 328 //Handle Required on Radiobutton & Checkbox Allow Other 329 //Code Commented since Valiation Plugin is unable to handle the error placement for a Textbox that's inside a label 330 //$('.Field.Radiobutton input:not([type=hidden]),.Field.Checkbox input[type=checkbox]:not([type=hidden])').change(function () { 331 // if ($(this).val() == 'Other') { 332 // $(this).closest('.Field-Container').find('input[type=text]').removeClass('nrequired').attr('required', ''); 333 // } else { 334 // $(this).closest('.Field-Container').find('input[type=text]').addClass('nrequired').removeAttr('required'); 335 // } 336 //}); 337 338 339 // Initialize validation on the entire ASP.NET form. 340 jQuery.validator.setDefaults({ 341 //debug: true, 342 onsubmit: false, 343 ignore: ".novalidate", 344 rules: { 345 success: function (error) { 346 error.remove(); 347 } 348 }, 349 errorPlacement: function (error, element) { 350 351 if (element.closest('.Field').hasClass("Radiobutton")) { 352 error.insertAfter(element.closest('.Field').find('.Field-Container')); 353 error.insertAfter(element.closest('.Field').find('.Field-Container-Wide')); 354 return; 355 } 356 else if (element.closest('.Field').hasClass("Matrix")) { 357 if ($(element).attr('type') == 'radio' || $(element).attr('type') == 'checkbox') { 358 if ($(element).closest('tr').find('.tdBlank').find('.error').length < 1) 359 element.closest('tr').find('.tdBlank').append(error); 360 return; 361 } 362 else if ($(element).attr('type') == 'text' || $(element).attr('type') == 'number' || $(element).is('select')) { 363 $(element).closest('tbody').find('.tdBlank').find('.error').remove(); 364 $(element).closest('tbody').find('.tdBlank').first().append(error); 365 return; 366 } 367 } 368 else if (element.closest('.Field').hasClass("Phone")) { 369 if (element.hasClass('AreaCode')) 370 return; 371 } 372 else if (element.closest('.Field').hasClass("Checkbox") || element.closest('.Field').hasClass("Datetime") || element.closest('.Field').hasClass("Time") || element.closest('.Field').hasClass("Birthdate") || element.closest('.Field').hasClass("Fullname") || element.closest('.Field').hasClass("Address")) { 373 374 if (element.closest('.Field').find('label.error').length == 0 || (element.closest('.Field').find('label.error').length > 0 && element.closest('.Field').find('label.error').is(":visible") == false)) { 375 error.insertAfter(element.closest('.Field').find('.Field-Container')); 376 error.insertAfter(element.closest('.Field').find('.Field-Container-Wide')); 377 } 378 return; 379 380 } 381 382 383 384 error.insertAfter(element); 385 386 } 387 });
388 389 //$("#form1").validate({ 390 // // This prevents validation from running on every 391 // // form submission by default. 392 393 // onsubmit: false, 394 395 396 //}); 397 398 // Search for controls marked with the causesValidation flag 399 // that are contained anywhere within elements marked as 400 // validationGroups, and wire their click event up. 401 $('.validationGroup .causesValidation').click(ValidateAndSubmit); 402 403 // Select any input[type=text] elements within a validation group 404 // and attach keydown handlers to all of them. 405 $('.validationGroup :password,.validationGroup :text').keydown(function (evt) { 406 // Only execute validation if the key pressed was enter. 407 if (evt.keyCode == 13) { 408 ValidateAndSubmit(evt); 409 } 410 }); 411}); 412 413function ValidateAndSubmit(evt) { 414 415 //Show the loading icons 416 jQuery(".lfoverlay").show(); 417 jQuery(".lfmodal").show(); 418 419 //Finish client side operations 420 $('.Field.Currency input').each(function () { 421 $(this).next().val($(this).maskMoney('unmasked')[0]); 422 }); 423 424 425 426 $('.Field.Dropdown select').each(function () { 427 $(this).prev().val($(this).find('option:selected').text()); 428 }); 429 430 $('.Field.Radiobutton table').each(function () { 431 $(this).prev().val($(this).find('input:checked').next().text()); 432 }); 433 434 $('.Field.Checkbox table').each(function () { 435 $(this).prev().val($(this).find('input:checkbox:checked').map(function () { 436 return $(this).next().text(); 437 }).get().join(',')); 438 }); 439 440 441 442 443 // Ascend from the button that triggered this click event 444 // until we find a container element flagged with 445 // .validationGroup and store a reference to that element. 446 447 var $group = $(evt.currentTarget).parents('.validationGroup'); 448 449 var isValid = true; 450 // Descending from that .validationGroup element, find any input 451 // elements within it, iterate over them, and run validation on 452 // each of them. 453 $group.validate(); 454 var focus = new Array(); 455 $group.find(':input').each(function (i, item) { 456 if ($(item).is(':visible') && !$(item).valid()) { 457 focus.push(item); 458 isValid = false; 459 } 460 else if ($(item).attr('furequired') == "furequired" && !$(item).valid()) { 461 focus.push(item); 462 isValid = false; 463 } 464 else if ($(item).attr('fbrequired') == "fbrequired" && !$(item).valid()) { 465 focus.push(item); 466 isValid = false; 467 } 468 else if ($(item).attr('ckeditor') == "required") { 469 if ($(item).parent('div').attr('editorrequired') != undefined && $(item).parent('div').attr('editorrequired') == "true") { 470 $.each(CKEDITOR.instances, function (key, editor) { 471 if ($(editor.element.$).parent('div').parent('li') != undefined && $(editor.element.$).parent('div').parent('li').is(':visible') == true) { 472 if ($(item).attr('ckeditor') == $(editor.element.$).attr('ckeditor')) { 473 if (editor.getData() == "") { 474 $("#label" + $(item).attr('ckeditor') + "").remove(); 475 $("<label id=label" + $(item).attr('ckeditor') + " class=\"error\">" + LFValidations.required + "</label>").insertAfter($(item).parent('div').children('div')); 476 isValid = false; 477 } 478 else { 479 $("#label" + $(item).attr('ckeditor') + "").remove(); 480 } 481 } 482 } 483 }) 484 } 485 } 486 var pagesection_Visible = true; 487 var pagesection = $(item).closest('ul.page-break-section'); // in case of multiple captcha in a form with page breck 488 if (pagesection && !$(pagesection).is(':visible')) 489 pagesection_Visible = false; 490 if (pagesection_Visible && $(item).hasClass('g-recaptcha-response') && !$(item).hasClass('novalidate')) { 491 var captchadiv = $(item).closest('div[googlerecaptchaid]'); 492 var captcharesponse = grecaptcha.getResponse($(captchadiv).attr('googlerecaptchaid')); 493 $("#" + $(captchadiv).attr("id") + " .error").remove(); 494 if (captcharesponse.length == 0) { 495 isValid = false; 496 $("#" + $(captchadiv).attr("id")).append('<label class="error">' + LFValidations.recaptcha + '</label>'); 497 } 498 499 } 500 501 });
502 //password validate 503 $group.find('.Field.Password').each(function (i, item) { 504 var password = "", confirmpassword = ""; 505 $(item).find(':input').each(function (i, inputitem) { 506 if ($(inputitem).is(':visible')) { 507 $(inputitem).next('.conmessage').remove(); 508 if ($(inputitem).hasClass('password')) { 509 password = inputitem.value; 510 } 511 else if ($(inputitem).hasClass('confirmpassword')) { 512 $(inputitem).next('.conmessage').remove(); 513 confirmpassword = inputitem.value; 514 if (password != confirmpassword) { 515 focus.push(inputitem); 516 $('<label class="error conmessage">' + LFValidations.matchpassmessage + '</label>').insertAfter(inputitem); 517 isValid = false; 518 } 519 } 520 } 521 }); 522 523 }); 524 525 526 //validate Extension fields 527 isValid = ValidateExtension($group, focus, isValid); 528 529 if ($(focus).length > 0) { 530 $('html,body').animate({ scrollTop: $(focus).first().closest('li').first().offset().top - 100 }, 500, function () { $(focus).first().focus(); }); 531 //$(focus).first().focus(); 532 } 533 // If any fields failed validation, prevent the button's click 534 // event from triggering form submission. 535 if (!isValid) { 536 jQuery(".lfoverlay").hide(); 537 jQuery(".lfmodal").hide(); 538 evt.preventDefault(); 539 } 540 else if (evt.keyCode == 13) { 541 var SubmitButton = $group.find('.causesValidation.bSubmit'); 542 if (SubmitButton.length > 0) { 543 SubmitButton.click(); 544 evt.preventDefault(); 545 } 546 } 547 //else { 548 549 // var url = window.location.href; 550 // if (url.indexOf("?") > -1) 551 // url = url + '&mid=' + parseInt($(this).attr("mid")); 552 // else 553 // url = url + '?mid=' + parseInt($(this).attr("mid")); 554 555 // $.post(url, $('form').serializeArray()).done(function (data) { 556 // var $group = $(evt.currentTarget).parents('.validationGroup'); 557 // var SubmitButton = $group.find('.causesValidation.bSubmit'); 558 // jQuery(".lfoverlay").hide(); 559 // jQuery(".lfmodal").hide(); 560 // var html = $.parseHTML(data); 561 // var dom = $(data); 562 // $('body').find('[uniqueid="LiveForm' + parseInt($(SubmitButton).attr("mid")) + '"]').html(dom.find('[uniqueid="LiveForm' + parseInt($(SubmitButton).attr("mid")) + '"]').html()); 563 // $.each($(data).find('script'), function (k, v) { 564 // var src = $(v).attr("src"); 565 // if (src != undefined && src.indexOf("DesktopModules/LiveForms") != -1) { 566 // eval(v); 567 // } 568 // }); 569 // }) 570 // evt.preventDefault(); 571 //} 572}
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.