I need a customized validation check for my order form where users are asked to enter their server hostname. The challenge is that I'm using WHMCS with encrypted PHP code and IonCube loaders, making it difficult to add this check.
Users can input any hostname they want, like user1.abc.com, but I want the final result to always be user1.domain.com, with "domain.com" being the fixed domain of my choice due to automatic DNS entry creation upon container/VM setup.
Is there a way to implement this validation using JavaScript? It's worth noting that WHCMS utilizes .tpl template files for the order form.
My initial idea involves crafting a regex pattern:
/^[a-z\d]([a-z\d\-]{0,61}[a-z\d])?(\.[a-z\d]([a-z\d\-]{0,61}[a-z\d])?)*$/i
While this regex offers general hostname validation, I specifically require it to enforce the use of "domain.com."
To elaborate further, if a user types in user1.abc.com, the form should automatically correct this to user1.domain.com.