1var Validator = {}; 2 3Validator.isValid = function ($elm) { 4 var isValid = true; 5 $($elm).find('.req-field').each(function () { 6 if(!$(this).is(":visible")){ 7 return true; 8 } 9 var extraConditionFailed = false; 10 if ($(this).attr("type") == 'email'){ 11 extraConditionFailed = !Validator.isEmail($(this).val()) 12 } 13 if ($(this).attr("type") == 'password'){ 14 extraConditionFailed = !Validator.passwordLength($(this).val()) 15 } 16 if ($(this).attr("name") == 'nipt'){ 17 if ($(this).val() != ''){ 18 extraConditionFailed = !Validator.correctNuis($(this).val()) 19 } 20 } 21 if ($(this).val() === '' || $(this).val() == null || extraConditionFailed) { 22 if ($(this).hasClass("select2")) { 23 $(this).parent().find('span.select2-selection').addClass('select-has-error'); 24 $(this).closest('.form-group').addClass('has-error'); 25 $(this).parent().find('.invalid-feedback').show(); 26 27 $(this).addClass('has-error'); 28 $(this).addClass('select-has-error'); 29 } else if ($(this).closest('.form-group').length > 0) { 30 $(this).closest('.form-group').addClass('has-error'); 31 $(this).addClass('has-error'); 32 $(this).parent().find('.invalid-feedback').show(); 33 } else { 34 $(this).addClass('has-error') 35 $(this).parent().find('.invalid-feedback').show(); 36 } 37 isValid = false; 38 } else { 39 if ($(this).hasClass("select2")) { 40 $(this).parent().find('span.select2-selection').removeClass('select-has-error'); 41 $(this).closest('.form-group').removeClass('has-error'); 42 $(this).parent().find('.invalid-feedback').addClass('hidden'); 43 } else if ($(this).closest('.form-group').length > 0) { 44 $(this).closest('.form-group').removeClass('has-error'); 45 $(this).removeClass('has-error'); 46 $(this).parent().find('.invalid-feedback').hide(); 47 } else { 48 $(this).parent().find('.invalid-feedback').hide(); 49 $(this).removeClass('has-error') 50 } 51 } 52 }); 53 return isValid; 54}; 55 56Validator.isEmail = function (email) { 57 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 58 return regex.test(email); 59} 60 61Validator.passwordLength = function (password){ 62 return password.length >= 8; 63} 64 65Validator.correctNuis = function (nuis){ 66 var regex = /^\w{1}\d{8}\w{1}$/; 67 return regex.test(nuis); 68}
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.