What's missing to make it work?

this script inserted in a block should verify the correctness of the Italian tax code, but it is not activated, what is missing?

<script>
                if (s.hasClass("cm-codice-fiscale") && s.hasClass("to-check")) {
                    var cf = _checkCodiceFiscale(r.val());
                    console.log("controllo cf:"+cf);
                    if ((0 == cf || "invalidlength" == cf) && (s.hasClass("cm-required") || 0 == o.a.is.blank(r.val()))) {
                        var C = "error_validator_codice_fiscale";
                        "invalidlength" == cf && (C = "error_length_codice_fiscale"), (de(ie.tr("error_validator_codice_fiscale"), s), n = !0)
                    }
                  }
                  if (s.hasClass("cm-partita-iva")) {
                    var pi = _checkPartitaIva(r.val());
                    if ((0 == pi || "invalidlength" == pi) && (s.hasClass("cm-required") || 0 == o.a.is.blank(r.val()))) {
                        var C = "error_length_partita_iva";
                        "invalidlength" == pi && (C = "error_length_partita_iva"), (de(ie.tr("error_length_partita_iva"), s), n = !0)
                    }
                  }

</script>

I recommend you to use for validators. More details can be found here

https://docs.cs-cart.com/latest/developer_guide/core/front-end/microformats.html?highlight=validator

1 Like