prestashopprestashop-1.7

Prestashop 1.7 : dni is invalid when creating a supplier from B.O


Every time i'm trying to create a supplier from BackOffice, an error message is appeared: "dni is invalid" because invalid characters.

i have changed "isDniLite" in "validate.php" file but no luck.

i need that field to accept anything.

I am using Prestashop V1.7.7.0

Need help please. Thanks.


Solution

  • You have to go to the file yourshop\classes\Validate.php

    In this file scroll down until you see function isDniLite($dni) and add following line:

    public static function isDniLite($dni)
    {
        return $dni; // Crezzur: Don't check, just accept variable input.
        // Disable the old return just to be sure:
        // return empty($dni) || (bool) preg_match('/^[0-9A-Za-z-.]{1,16}$/U', $dni);
    }
    

    The best practice is to write an override for this. But this is your free choice.

    Update: Additional there is another place where a check for DNI is placed

    You have to go to the file yourshop\js\validate.js

    In this file scroll down until you see validate_isDniLite(s) and add following line:

    function validate_isDniLite(s)
    {
        return s;
        // var reg = /^[0-9a-z-.]{1,16}$/i;
        // return reg.test(s);
    }