Magento – How to Change Custom Validation Error Message

magento2validation

In Magento 2 How to change Sign up Error message

I want to change this Minimum of different classes of characters in password is 3. Classes of characters: Lower Case, Upper Case, Digits, Special Characters. Where i need to change this error message

enter image description here

Best Answer

I found this solution and it worked for me. Add data-validate='{"telephone-check-maximum-length-15":true}' in your input tag. And add below javascript at the end of your phtml file.

<script type="text/javascript">
require([
    'jquery', // jquery Library
    'jquery/ui', // Jquery UI Library
    'jquery/validate', // Jquery Validation Library
    'mage/translate' // Magento text translate (Validation message translte as per language)
], function($){ 
    $.validator.addMethod(
        'telephone-check-maximum-length-15', function (value) {
            return (value.length<15); // Validation logic here
            },
        $.mage.__('Please enter less or equal than 15 digits.')
    );
});
</script>
Related Topic