Created
January 18, 2021 00:14
-
-
Save patrickfreitasdev/4187cf2f9bc8a6e3ef2c01e2436b58f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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