I’m not good at Javascript and searched the forum but couldn’t find an answer. I have a WordPress site and using the WPForms plugin. I have a number type
input in my form. I want to validate the max 11 character number entry in that input. I searched WPForms documents and found that code and inserted it to template’s function.php
file:
function wpf_vergi_no() {
?>
<script type="text/javascript">
jQuery(function($){
$('.wpf-vergi-no input').attr({'min':1000000000, 'max':9999999999}); // Define number limits
});
</script>
<?php
}
add_action( 'wpforms_wp_footer_end', 'wpf_vergi_no', 9999999999 );
It’s working and showing a validation message but I want to customize that message. Anyone can help me with this?
Thanks 🙂
2
Answers
To change the default HTML5 validation warnings you can use
setCustomValidity()
within theinvalid
event, like this:You can override the message using
wpformsReady
and$.validator
check the below code.Here is the list of default messages.
Tested and works.