How to add validation to an inline grid addRowLink?

I have an Inline Grid created, which has addRowLink, used to create a new row each time it is clicked but the scenario is that the user should not be able to click that link more than 5 times, i.e. after creating a 5th row, the link should be disabled and a validation error should be thrown. Any suggestions appreciated?

  Discussion posts and replies are publicly visible