Jump to content

Regex for fields from additionalfields.php


DennisHermannsen

Recommended Posts

On 04/01/2019 at 10:47, DennisMidjord said:

Is it possible to have regex validation on some fields from additionalfields.php?

from admin configuration settings, no; from options within additionalfields, no.

https://requests.whmcs.com/topic/additionaldomainfields-validation

it can be done by editing the template and, by implication, with an action hook too... for example, I could apply a minimum and/or maximum length to a field using HTML5 patterns...

QTfWhHI.png

as i've done in other threads, I could make that error message in the client's own language if necessary.

this was done with a quick IF statement in the template, but effectively you're just manipulating the $domain.fields array, so that's why I know you could do it as a hook if you wanted to.

you could even regex VAT ID fields if you had to for the correct format for each country - though note that it's just checking formats, and not querying the actual VAT number with VIES to check whether it exists.

Sdwgbsc.png

if I remove the spaces from WHMCS' VAT number, then the regex would pass successfully and the order can continue.

I assume that there are no additionaldomainfields validation options in the v7.7 betas ? i'm not installing the RC until at least next week, so I don't know but saw nothing in the changelogs.

if you were validating multiple fields for multiple TLDs, then you may be better off with a hook to avoid complicated if statements in the template... but either way, this could very easily get very messy very quickly - not least because you'll have to check the TLD before modifying the array fields - and as there's no specific TLD field, you'd have to create it from other variables... there could be other issues that haven't even occurred to me, so this could be an absolute minefield if you really want to start validating these fields! ⚠️

it might be useful for me to have 3 practical TLD examples where this could be used.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated