Disable add row link or show error after certain number of rows of added to grid

Hi 

I have a requirement where user provides no of employee details he want to add in an UI and after the UI there is editable grid where user enters the details, I need to limit the user to add rows that are equal or less than number he gave in the previous UI. 

How can I achieve this. Please help

Thanks in advance.

  Discussion posts and replies are publicly visible