Prevent the modal from closing when you click the page

I’m using the openModal( ) function to open modals with dynamic URLs. These modals contain fields which must be filled out. It’s detrimental to the user experience for the modal to close out when someone clicks on the page space outside of the modal. This erases all the inputs the user had already gone through. I would like to see a way to keep the modal open when a visitor clicks outside the modal onto the page. The only way I would like them to be able to close the modal is the ‘x’ in the top right corner.

Previous post here