I
I
Ivseti2021-07-26 09:51:57
JavaScript
Ivseti, 2021-07-26 09:51:57

How to add validation for the field in Latin letters Contact form?

Good day. I use this validation for CF7.

For certain fields, this solution works great. For example, now I have it set up like this:

add_action('wp_footer', 'wpmidia_activate_masked_input');
function wpmidia_activate_masked_input(){
?>
<script type="text/javascript">
jQuery( function($){
$(".tel").mask("+79999999999");
$(".inn").mask("999999999999");
$(".snils").mask("99999999999");
$(".card").mask("9999999999999999");
$(".codrazdel").mask("999999");
});
</script>
<?php
}


The script has three outputs 9 - only numbers, a - Latin letters, * - here I made numbers, Latin letters and Cyrillic.

By the mask above, you can set a certain number of characters, but I have fields, for example, a name on a bank card, there may be a different number of characters, how to do it in order to prescribe a mask for the field, only Latin letters, but without limitation on number of characters. So if you do $(".mycart").mask("aaaaaaaa-aaaaaaaa"); then if all the characters are not filled, then the field will not be filled.

upd.
I found instructions for this mask, but so far I can’t figure out how to remove the limit on the number of input characters, so that one condition would work, for example, input in the field only in Latin, I look at github .

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question