function today() { var now = new Date(); var day = now.getDate(); var month = now.getMonth() + 1; var year = now.getFullYear(); return (day < 10 ? "0" : "") + day + "-" + (month < 10 ? "0" : "") + month + "-" + year; } var arrInvalidEmails = new Array(); var arrValidEmails = new Array(); $j(document).ready(function() { $j.validator.addMethod("fluxform_datefield", function(value, element) { value = $j.trim(value); var err = false; if ($j(element).hasClass("fluxform_backend_allow_prefill_value") && /^%{2}user_[^%]*?%{2}$/.test(value)) { } else if ($j(element).val().length > 0) { value = value.replace(/\//g, "-"); value = value.replace(/\./g, "-"); tmp = value.split("-"); if (tmp.length != 3) { err = true; } else { year = parseInt(tmp[2],10); month = parseInt(tmp[1],10) - 1; day = parseInt(tmp[0],10); var test = new Date(year, month, day); if (year != test.getFullYear() || month != test.getMonth() || day != test.getDate()) err = true; } if (!err) { $j(element).val((day < 10 ? "0" : "") + day + "-" + (month + 1 < 10 ? "0" : "") + (month + 1) + "-" + year); } return (!err); } return this.optional(element) || !err; }, "Gelieve een geldige datum in te voeren. Correcte datumnotatie: 'dd-mm-jjjj'. (vb. %date)".replace(/%date/, today())); $j.validator.addMethod("fluxform_numberfield", function(value, element) { var err = false; if ($j(element).hasClass("fluxform_backend_allow_prefill_value") && /^%{2}user_[^%]*?%{2}$/.test(value)) { } else { err = !/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); } return this.optional(element) || !err; }, "Vul hier een geldig getal in."); $j.validator.addMethod("fluxform_numberfield_integer", function(value, element) { value = $j.trim(value); var err = false; if ($j(element).hasClass("fluxform_backend_allow_prefill_value") && /^%{2}user_[^%]*?%{2}$/.test(value)) { } else { err = !/^-?\d+$/.test(value); } return this.optional(element) || !err; }, "Gelieve een geheel getal in te vullen."); $j.validator.addMethod("fluxform_numberfield_positive", function(value, element) { value = $j.trim(value); var err = false; if ($j(element).hasClass("fluxform_backend_allow_prefill_value") && /^%{2}user_[^%]*?%{2}$/.test(value)) { } else { err = !/^(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); } return this.optional(element) || !err; }, "Gelieve een positief getal in te vullen."); $j.validator.addMethod("fluxform_multiselectfield_required", function(value, element) { var fields = $j("input[name='" + element.name + "']").serializeArray(); return (fields.length > 0); }, "Gelieve minstens 1 optie aan te duiden."); $j.validator.addMethod("fluxform_emailfield", function(value, element) { var err = false; if ($j.inArray(value, arrValidEmails) != -1) { } else if ($j(element).hasClass("fluxform_backend_allow_prefill_value") && /^%{2}user_[^%]*?%{2}$/.test(value)) { } else if ($j.inArray(value, arrInvalidEmails) != -1) { err = true; } else { $j.ajax({ cache: false, async: false, type: "post", data: "email=" + value, url: "/includes/check_email.php", success: function(msg) { if (msg == "false") { err = true; arrInvalidEmails.push(value); } else { arrValidEmails.push(value); } } }); } return this.optional(element) || !err; }, "Vul hier een geldig email adres in."); $j.validator.addMethod("fluxform_urlfield", function(value, element) { var err = false; if ($j(element).hasClass("fluxform_backend_allow_prefill_value") && /^%{2}user_[^%]*?%{2}$/.test(value)) { } else { err = !/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); } return this.optional(element) || !err; }, "Vul hier een geldige URL in."); });