A recent customer request was to have the linux machine names entered manually, always be in lower case, and be 13 characters long.
Initially I tinkered with a basic Event Broker Service (EBS) Subscription to simply change the ‘Hostname’ to lower case, but then decided to enforce it in a custom form.
My first task was finding the correct expression using some search sites. After a few clicks I was able to find what I was looking for.
My working expression ended up looking like this.
^[a-z0-9]{13}$
Click on the Hostname field on your custom form, then the Constraints tab and paste the expression in Regular expression, and provide a useful error in the Validation error message text box.
Make sure to click the form Save button before moving to another field. I failed to do that a few times, only to discover a blank field when troubleshooting.
While the customer didn’t have a specific requirement for the other fields, I decided to research and test some other expressions for future reference. I’m sure some additional tweaking will be needed, but here goes.
IP Address / DNS Server / Gateway
^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
Subnet Mask
^(((255\.){3}(255|254|252|248|240|224|192|128|0+))|((255\.){2}(255|254|252|248|240|224|192|128|0+)\.0)|((255\.)(255|254|252|248|240|224|192|128|0+)(\.0+){2})|((255|254|252|248|240|224|192|128|0+)(\.0+){3}))$
Domain name
(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]
There you go. As always your mileage may vary.
that helped me.. thnx!
LikeLike