The following script added to the on add - validate block of the Script tab, checks if the number of records in the Registration form is equal to or greater than 20. Here, the count function is used to count the number of records in the Registration form. If the condition is satisfied, displays an alert message to the user and cancels the submission, so that the record is not stored in database.
if(count(Employee[ID != 0]) >= 20) |
Also refer the sample application Course Registration, which restricts the number of registrations to a specific course, based on the seats available.