AFAIK, Marathi uses same script as Hindi. In that you can't easily tell which language is used.
Easier way to detect language if your text is written using Unicode is by checking the character range. If the character range is in between the range for Hindi, you can assume it is Hindi. But you need to scan till the end and if all the characters are in Hindi, the word is written in Hindi. Your algorithm should also consider zero-width joiner and non joiners (ZWJ & ZWNJ) while scanning the input. I have done an implementation of language detection. You can find code here[^]. It is written in C but the concepts are same for any language.
If i select 2 schools per region i should get error message.
Sounds like straight forward implementation. On page submit, check for the number of regions selected - if more then one, check number of schools for a region - if more then one, throw an error message.