Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save patrickfreitasdev/4187cf2f9bc8a6e3ef2c01e2436b58f4 to your computer and use it in GitHub Desktop.
Save patrickfreitasdev/4187cf2f9bc8a6e3ef2c01e2436b58f4 to your computer and use it in GitHub Desktop.
<?php
add_action( 'wp_footer', function(){ ?>
<script>
(function ($) {
$(function () {
$(document).on("after.load.forminator", function (e, id) {
var cvalinput = $('.custom-validate input');
let regx = /^[0-9]*$/;
$(cvalinput).bind('focusout keyup ', function () {
if (regx.test($(this).val()) || $(this).val() === '') {
$(this).parent().parent().find('label.forminator-label--validation').remove();
} else {
if (!$(this).parent().parent().find('label.forminator-label--validation').length) {
$(this).parent().parent().append('<label class="forminator-label--validation">Only alphanumeric characters are allowed.</label>');
}
}
});
});
});
})(window.jQuery);
</script>
<?php }, 21); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment