Jump to content

Recommended Posts

Hello,

 

I have been looking at how to do validation on custom fields.  I can't find much info.

How would i do the 2 below validation strings?

 

(Panel Username)  - (Leave empty if you want system generates randomly), 6 to 28 characters in length, alpha-numeric or underscores only, DO NOT use email address, space, @, /, or other special characters.

(Panel Password) - (Leave empty if you want system generates randomly), 6 to 28 characters in length, alpha-numeric and underscores only.

 

 

thanks

 

Share this post


Link to post
Share on other sites

Forgot i believe this is the string

 

/^[a-z\d_]{6,28}$/i
I think this is right.  Not sure about capital letters and if customer leaves blank

Share this post


Link to post
Share on other sites

yes this string is correct found last night on whmcs website.

Is there a short code for special characters or do i need to list each one

Share this post


Link to post
Share on other sites

I know this is the validation code for alpha numeric and underscore 6-28 characters      /^[a-z\d_]{6,28}$/i

Is there are special code for special characters like (*&^%$#@!><?"; etc. I don't what to have to type them all

Share this post


Link to post
Share on other sites
On 9/20/2022 at 12:16 AM, Dkuzik said:

Is there are special code for special characters like (*&^%$#@!><?"; etc. I don't what to have to type them all

If you want them to be allowed, then they have to be included in the character match.  For some of them, you may need to escape the character via a "\" before it.  Also, https://regex101.com/ helps greatly in testing and figuring out regex . 

Share this post


Link to post
Share on other sites

thanks.  I was hoping for short code on special characters but don't think there is.

This is my validation. /^[a-z\d~!@#$%^&*()-_=+[{]};:’”,<.>?|\/\\]{8,16}$/I

upper case lower case numbers special characters 8-16 characters long

Share this post


Link to post
Share on other sites

\W might be what you want then if you want all special characters to be valid.  Where \w matches letters, numbers - alphanumeric, \W matches non-letters, non-number - non-alphanumeric.

Share this post


Link to post
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