Hi Naucify,
If want to generate a auto number on a field. My suggestion is to prefer a custom plugin instead of javascript. Because If you do bulk import the records like using import to excel functionality then your JavaScript will not work, but Plugin will do.
So you can refer this blog to write a custom plugin. Or can be use this developed
solution directly.
Hope this will help you.
:-)
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.