Asking code from user on signup

Hi! I was wondering if there is anything already built in that could help us with what we’re looking to do:
We want to give organizations a code that will allow them to create only X users. Only someone with a code can create an account.
Is there any way on sign up to ask the user for the code he was given, then check if 1. the code corresponds to an organization and 2. if this organization can open any more accounts?
Thanks in advance