Closed emiljano539 closed 6 years ago
Hi @emiljano539 , can you provide the steps to reproduce the error?
Or if you can, a PR to fix it
Many thanks!
as reference -> https://github.com/heavybeard/codice-fiscale/blob/master/source/CodiceFiscale.js#L285
THE HTML CODE :
<html>
<script src="./CodiceFiscale.js" type="text/javascript"></script>
<script>
var person = new CodiceFiscale({
name: 'Mario',
lastname: 'Rossi',
day: '25',
month: '04',
year: '1945',
isMale: true,
communeName: 'Milano'
});
console.log(person.taxCode()); // RSSMRA45D25F205N
console.log(person.lastnameCode()); // RSS
person.nameCode(); // MRA
person.dateCode(); // 45D25
person.yearCode(); // 45
person.monthCode(); // D
person.dayCode(); // 25
person.communeCode(); // F205
person.controlChar(); // N
</script>
</html>
Is showing the error. Where is the mistake ? Am i missing something in the javascript code or what?
The console log :
Uncaught TypeError: Cannot read property '1' of undefined
at CodiceFiscale.communeCode (CodiceFiscale.js:285)
at CodiceFiscale.taxCode (CodiceFiscale.js:165)
at index.html:13
Understood! Thanks for your example.
You need to use the dist
version of the script, I suggest the minified version.
<script src="./CodiceFiscale.min.js" type="text/javascript"></script>
The source
version hasn't the cadastral codes list, so the undefined error comes up
Now it's working thanks. What about a reverse codicefiscale search? How can it be done?
How can i insert a codice fiscale that shows the birthday/birthplace or gender?
At the time the functionality you asked doesn't exist, but it can be a great feature. Unfortunately now I can't work on it, but I'll be glad to help who want to develop it.
If you think you can do it, you can fork this repo, work on the feature and return with a PR.
If you want you can work with strings (.substring
method maybe) for taking a specific info, it's not the most elegant way, but it works
Issue in line 285 of CodiceFiscale.js for the commune recognition : return this._commune()[0][1];