Make the relationship mandatory in a custom module

hi,

I have Suitecrm 7.11.1.
I have a standard module1, and a custom Module2.
I have a one to many relationship between Module1 (one) and Module2 (many).

I need to make the relationship mandatory from Module2, so when I create a record in Module2 I’m forced to enter a Module1 record.

I understand it’s not feasible from the standard interface, does somebody know how to change the code to make it?

thank you,

Giulia

I don’t know exactly how to do it, but I would start from code samples using Javascript injection into the view, to make validations.

Like these

https://suitecrm.com/suitecrm/forum/developer-help/6921-viewedit-validation

Field validation with simple callback from vardefs:
https://gunnicom.wordpress.com/2015/09/21/suitecrm-sugarcrm-6-5-add-custom-javascript-field-validation/
http://sugarmods.co.uk/how-to-add-custom-validation-to-form-fields-in-sugarcrm