Jump to content

Preventing certain characters in first/last name


Ragonz

Recommended Posts

Yesterday we had someone sign up with a last name of ; this caused our product platform to not create an account as it could not create a username with ; in it, is there a way to prevent certain characters being used in the first/last name fields of WHMCS?

Link to comment
Share on other sites

11 hours ago, Ragonz said:

Yesterday we had someone sign up with a last name of ; this caused our product platform to not create an account as it could not create a username with ; in it, is there a way to prevent certain characters being used in the first/last name fields of WHMCS?

the usual two ways would be to..

  • edit the checkout/register templates and add a html5 pattern to those two fields in either/both templates - should literally be only one line of code per field.
    <input type="text" name="firstname" id="inputFirstName" class="field" placeholder="{$LANG.orderForm.firstName}" value="{$clientsdetails.firstname}" pattern="[a-zA-Z ]+" oninvalid="this.setCustomValidity('Please use valid alphanumeric characters')" oninput="setCustomValidity('')" {if $loggedin} readonly="readonly"{/if} autofocus>

    7TPsEjU.png
    so in the above example, i've coded the error message in English, but you could equally use a language string in that code to ensure the error was shown in the clients language.... for surnames, you will probably have to extend the pattern to use ' and - etc.

  • use a ClientDetailsValidation action hook to check the format of those fields and return an error message if applicable.

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