Created
May 26, 2020 14:31
-
-
Save Soft-Designs/f114c90795eddee826d0343d562dc8f6 to your computer and use it in GitHub Desktop.
WPMU-Forminator-Custom-Validation
This file contains 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 ( $ ) { | |
$( document ).ready( function() { | |
var cvalinput = $( '.custom-validate input' ), | |
regx = /^[A-Za-z0-9]+$/; | |
$( cvalinput ).focusout( 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>' ); | |
} | |
} | |
} ); | |
} ); | |
} ( jQuery ) ) | |
</script> | |
<?php | |
}, | |
999 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment