{"version":3,"sources":["forms.validation.js"],"names":["app","formValidation","let","validationService","aspnetValidation","ValidationService","initRequiredRadioButtons","document","querySelectorAll","element","forEach","errorMessage","form","radio","setAttribute","getAttribute","classList","inputName","init","add","countryField","querySelector","params","checked","value","country","addProvider","test","checkedOption","remove"],"mappings":"AAAAA,IAAIC,eAAkB,wBAGpBC,IAAIC,EAAoB,IAAIC,iBAAiBC,kBAE7C,SAASC,IACPC,SAGIC,iBAAkBC,iDAClBC,QAAMC,SAAAA,GAENF,IAAQG,EACLJ,EAAAA,aAAiB,QAEhBK,MAAMC,EAAaL,EAAnBM,aAAA,0BAEAF,EAAMG,KALVR,iBAAA,UAAAS,EAAA,MANJP,QAAA,SAAAG,GAcDA,EAAAC,aAAA,WAAA,QAJSD,EAAMC,aAAa,yBAA0BH,GAM9CO,EAAOF,UAAAG,IAAA,sBAwDhB,MAAO,CACLD,KAzDF,WAEEf,EAQUiB,YAAsB,aAAMC,SAAAA,EAChCZ,EAAAa,GARJ,OAAOb,EAAQc,UAIjBpB,EAUiBiB,YATf,yBACA,SAACI,EAUIf,EAAAa,GACFF,EAAAX,EAAAG,KAAAS,cATC,UAAYC,EAAOG,QAAU,MAG/B,GAAqB,OAAjBL,EAAuB,CAa/BjB,GAA8B,QAA9BA,EAAkBuB,MACVT,MAAAA,wCAANU,KAAAH,GACMI,GAA6BP,QAA7BO,EAAgBnB,MAXhB,MAAO,sBAAsBkB,KAAKH,GAItC,OAeS,IAVbrB,EAiBKK,YAAAA,gBAA6BS,SAAAA,EAAZR,EACjBC,GAjBH,IAkBIG,EAAgBgB,EAAOd,aAAA,QAnB7B,OAAA,OAoB0BN,EAAAG,KAAAS,cAJxB,UAAAJ,EAAA,eASFX,EAAAA,KAGFE,iBAAA,UAAAS,EAAA,MApBSP,QAAQ,SAACG,GACRA,EAAMG,UAAUa,OAAO,0BAoB1BhB,EAAAG,UAAAG,IAAA,6BAGLhB,IAhBEM,EAAQG,KAoBVX,iBAAJ,UAAAgB,EAAA,MAlBSP,QAAQ,SAACG,GACRA,EAAMG,UAAUa,OAAO,0BACvBhB,EAAMG,UAAUG,IAAI,6BAEjB,KAGTb,KAMAA,yBAA0BA,EAC1BH,kBAAmBA,GAjFD,GAqFtBH,IAAIC,eAAeiB","file":"../forms.validation.min.js","sourcesContent":["app.formValidation = (function () {\r\n 'use strict';\r\n\r\n let validationService = new aspnetValidation.ValidationService();\r\n\r\n function initRequiredRadioButtons() {\r\n document\r\n .querySelectorAll('[data-val-requiredradio]:not(.is-initialized)')\r\n .forEach((element) => {\r\n const inputName = element.getAttribute('name');\r\n const errorMessage = element.getAttribute('data-val-requiredradio');\r\n\r\n element.form\r\n .querySelectorAll('[name=\"' + inputName + '\"]')\r\n .forEach((radio) => {\r\n radio.setAttribute('data-val', 'true');\r\n radio.setAttribute('data-val-requiredradio', errorMessage);\r\n radio.classList.add('is-initialized');\r\n });\r\n });\r\n }\r\n\r\n function init() {\r\n // mustbetrue validation (checkbox)\r\n validationService.addProvider('mustbetrue', (value, element, params) => {\r\n return element.checked;\r\n });\r\n\r\n // postalcodecountrycombo validation\r\n validationService.addProvider(\r\n 'postalcodecountrycombo',\r\n (value, element, params) => {\r\n const countryField = element.form.querySelector(\r\n '[name=\"' + params.country + '\"]'\r\n );\r\n\r\n if (countryField !== null) {\r\n if (countryField.value === 'NLD') {\r\n return /^[1-9]{1}[0-9]{3}\\s{0,1}[a-zA-Z]{2}$/g.test(value);\r\n } else if (countryField.value === 'BEL') {\r\n return /^[1-9]{1}[0-9]{3}$/g.test(value);\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n );\r\n\r\n // requiredradio validation (radio buttons)\r\n validationService.addProvider('requiredradio', (value, element, params) => {\r\n const inputName = element.getAttribute('name');\r\n const checkedOption = element.form.querySelector(\r\n '[name=\"' + inputName + '\"]:checked'\r\n );\r\n if (checkedOption !== null) {\r\n element.form\r\n .querySelectorAll('[name=\"' + inputName + '\"]')\r\n .forEach((radio) => {\r\n radio.classList.remove('input-validation-error');\r\n radio.classList.add('input-validation-valid');\r\n });\r\n\r\n return true;\r\n }\r\n\r\n element.form\r\n .querySelectorAll('[name=\"' + inputName + '\"]')\r\n .forEach((radio) => {\r\n radio.classList.remove('input-validation-valid');\r\n radio.classList.add('input-validation-error');\r\n });\r\n return false;\r\n });\r\n\r\n initRequiredRadioButtons();\r\n }\r\n\r\n // Expose public functions and variables\r\n return {\r\n init: init,\r\n initRequiredRadioButtons: initRequiredRadioButtons,\r\n validationService: validationService,\r\n };\r\n})();\r\n\r\napp.formValidation.init();\r\n"]}