/*! * gentleform - v2.0.1 * Accessible and user-friendly HTML5 form validation library. * https://github.com/Zhouzi/GentleForm * * @author Gabin Aureche * @license MIT */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.GentleForm=e():t.GentleForm=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([/*!***************************!*\ !*** ./src/GentleForm.js ***! \***************************/ function(t,e,r){"use strict";function n(t){function e(){n(t,"submitted",!0),c(t),o().forEach(c);for(var e=arguments.length,r=Array(e),i=0;e>i;i++)r[i]=arguments[i];v.apply(b,r)}function r(){o().forEach(s)}function n(t,e,r){var n=t.getAttribute("name"),i=u('[data-states-for="'+n+'"]'),a=[t].concat(i),o="is-"+e;r?a.forEach(function(t){return t.classList.add(o)}):a.forEach(function(t){return t.classList.remove(o)})}function a(t,e){var r="is-"+e;return t.classList.contains(r)}function u(e){return[].slice.call(t.querySelectorAll(e))}function o(){return u("input").filter(function(t){var e=t.getAttribute("name"),r=["button","submit","reset","file"];return-1===r.indexOf(e)}).concat(u("textarea, select"))}function c(t){t.checkValidity()?(t.removeAttribute("aria-invalid"),n(t,"valid",!0),n(t,"invalid",!1)):(t.setAttribute("aria-invalid","true"),n(t,"valid",!1),n(t,"invalid",!0)),s(t)}function s(t){var e=t.getAttribute("name"),r=t.validity,n=function(t){if("valid"===t)return"continue";var n=r[t]===!1,i=u('[data-errors-for="'+e+'"] [data-errors-when="'+t+'"]');i.forEach(function(t){n?l(t):f(t)})};for(var i in r){n(i)}}function f(t){t.style.display="",t.removeAttribute("aria-hidden")}function l(t){t.style.display="none",t.setAttribute("aria-hidden","true")}function d(){u("[data-include]").forEach(function(t){var e=t.getAttribute("data-include");null==m[e]&&(m[e]=document.getElementById(e).innerHTML),t.innerHTML=m[e]})}function p(){u("[required], [aria-required]").forEach(function(t){t.hasAttribute("required")?t.setAttribute("aria-required","true"):t.removeAttribute("aria-required")}),u("[data-errors-for]").forEach(function(t){t.setAttribute("role","alert"),t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true");var e=t.getAttribute("id");e||(e="gentle_"+i++,t.setAttribute("id",e));var r=t.getAttribute("data-errors-for"),n=u('[name="'+r+'"]')[0],a=n.getAttribute("aria-describedby")||"",o=a.split(" ");-1===o.indexOf(e)&&o.push(e),n.setAttribute("aria-describedby",o.join(" ").trim())})}var v=arguments.length<=1||void 0===arguments[1]?function(){}:arguments[1],b={updateMessages:r,updateIncludes:d,refreshAria:p,isValid:t.checkValidity.bind(t)},m={};return t.addEventListener("submit",e,!1),t.addEventListener("change",function(t){var e=t.target;n(e,"changed",!0),c(e)},!1),t.addEventListener("input",function(e){var r=e.target;(a(r,"changed")||a(t,"submitted"))&&c(r)},!1),d(),u("[data-errors-when]").forEach(l),p(),b}r(1);var i=0;t.exports=n},/*!***************************************************!*\ !*** ./~/html5validation/dist/html5validation.js ***! \***************************************************/ function(t,e){"use strict";!function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){var n={customError:r(1),badInput:r(2),typeMismatch:r(3),rangeUnderflow:r(4),rangeOverflow:r(5),stepMismatch:r(6),tooLong:r(7),patternMismatch:r(8),valueMissing:r(9)};[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement].forEach(function(t){"validity"in t.prototype||Object.defineProperty(t.prototype,"validity",{get:function(){var t={valid:!0};for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e](this),t[e]===!0&&(t.valid=!1));return t},configurable:!0}),"checkValidity"in t.prototype||(t.prototype.checkValidity=function(){var t=this.validity.valid;if(!t){var e=document.createEvent("Event");e.initEvent("invalid",!0,!0),this.dispatchEvent(e)}return t}),"willValidate"in t.prototype||(t.prototype.willValidate=!0),"setCustomValidity"in t.prototype||(t.prototype.setCustomValidity=function(t){try{this.validationMessage=t}catch(e){}})}),"checkValidity"in HTMLFormElement||(HTMLFormElement.prototype.checkValidity=function(){function t(t){return[].slice.call(e.querySelectorAll(t))}var e=this;return t("input").filter(function(t){return-1===["button","submit","reset"].indexOf(t.getAttribute("type"))}).concat(t("textarea, select")).every(function(t){return t.validity.valid===!0})})},function(t,e){t.exports=function(){return!1}},function(t,e){t.exports=function(){return!1}},function(t,e){var r=/^-?\d+$/,n=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,i=/(http(?:s)?\:\/\/[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,6}(?:\/?|(?:\/[\w\-]+)*)(?:\/?|\/\w+\.[a-zA-Z]{2,4}(?:\?[\w]+\=[\w\-]+)?)?(?:\&[\w]+\=[\w\-]+)*)$/;t.exports=function(t){var e=t.value,a=t.getAttribute("type");return"number"===a?!r.test(e):"url"===a?!i.test(e):"email"===a?!n.test(e):!1}},function(t,e){t.exports=function(t){if(!t.hasAttribute("min"))return!1;if("number"!==t.getAttribute("type"))return!1;var e=Number(t.value),r=Number(t.getAttribute("min"));return r>e}},function(t,e){t.exports=function(t){if(!t.hasAttribute("max"))return!1;if("number"!==t.getAttribute("type"))return!1;var e=Number(t.value),r=Number(t.getAttribute("max"));return e>r}},function(t,e){t.exports=function(t){if(!t.hasAttribute("step"))return!1;var e=t.getAttribute("type");if(-1===["number","range"].indexOf(e))return!1;var r=Number(t.value),n=Number(t.getAttribute("step"));return r%n!==0}},function(t,e){t.exports=function(t){if(!t.hasAttribute("maxlength"))return!1;if("number"===t.getAttribute("type"))return!1;var e=Number(t.getAttribute("maxlength"));return t.value.length>e}},function(t,e){t.exports=function(t){if(!t.hasAttribute("pattern"))return!1;var e=t.getAttribute("pattern"),r=new RegExp(e);return r.test(t.value)===!1}},function(t,e){t.exports=function(t){if(!t.hasAttribute("required"))return!1;var e=t.getAttribute("type")||t.tagName.toLowerCase();return"checkbox"===e?t.checked!==!0:"radio"!==e&&"range"!==e?0===t.value.length:!1}}])}])}); //# sourceMappingURL=GentleForm.min.js.map