How Can i make a number input filed unique in dataset?

How Can i make a number input filed unique in dataset ?

i need to make no duplicate entry in my Reg Number Filed

please help me I’m a beginner

You will first have to generate a number. If you want random, you should use Math.floor(Math.random()) (see https://www.w3schools.com/JS/js_random.asp)..) If you want incremented by 1, you will have to read/update a collection holding the last used number.
Then you will have to check (especially in case of random) if the number has not already been used. You can do that by:
-query the database with the generated number to see if it exists
-use the random number as _id and catch error if _id already exists.

If this makes no sense at all, maybe contract a with Expert.