Solved
Only two components can be added to page otherwise it gives error.
If more than two components are added, below error should pop-up.
How can I achieve this? Please help me out here.

If more than two components are added, below error should pop-up.
How can I achieve this? Please help me out here.

You can use ACS Commons Parsys limiter.
https://adobe-consulting-services.github.io/acs-aem-commons/features/parsys-limiter/index.html
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.