You can easily manage the custom validation using jquery with validation message. This is the simple code of jquery.
HTML code:
<input type="text" id="test_card"/> <span class="error_msg"></span>
Jquery Code:
var minLength = 10; var maxLength = 16; $(document).ready(function(){ $('#test_card').on('keydown keyup change', function(){ var char = $(this).val(); var charLength = $(this).val().length; if(charLength < minLength){ $('.error_msg').text('Length is short, minimum '+minLength+' required.'); }else if(charLength > maxLength){ $('.error_msg').text('Length is not valid, maximum '+maxLength+' allowed.'); $(this).val(char.substring(0, maxLength)); }else{ $('.error_msg').text('Length is valid'); } }); });
Question and answer is powered by AnsPress.io