Hi,
If your page component is different for each templates then you can find out pageResource in js and add validation on dialog submit
Granite.author.pageInfoHelper.json.pageResourceType
If your page component is same for mandatory and non-mandatory templates, the you can check template type using servlet and based on response add validation on dialog submit.
you can find page location in js using Granite.author.pageInfoHelper.json.status.path
Arun Patidar