Dynamics 365 How to force a leading space on Input control

I hope someone can help me as I am new to Dynamics.

There is a requirement in Dynamics 365 that says that an input field should have 6 characters min and allow spaces.

This is all good and I can do this with Javascript, but the requirement also states that the input can allow leading and trailing spaces(ie. _Rfbq2) the underscore is an example of a space, my challenge is that Dynamics 365 removes the leading or trailing spaces and this is a requirement as there is an integrated that uses this input, which can have leading and trailing spaces.

Is there a way I can force the leading space in Dynamics and override the OOB functionality that removes these spaces, is this something I can do with JS and regex somehow, any assistance would be appreciated as I have said I am mew to Dynamics