Dkuzik Posted September 4, 2022 Share Posted September 4, 2022 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 0 Quote Link to comment Share on other sites More sharing options...
Dkuzik Posted September 5, 2022 Author Share Posted September 5, 2022 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 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted September 6, 2022 Share Posted September 6, 2022 Hi Dkuzik, Are these custom fields on your order form? 0 Quote Link to comment Share on other sites More sharing options...
Dkuzik Posted September 7, 2022 Author Share Posted September 7, 2022 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 0 Quote Link to comment Share on other sites More sharing options...
Dkuzik Posted September 20, 2022 Author Share Posted September 20, 2022 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 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted September 21, 2022 Share Posted September 21, 2022 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 . 0 Quote Link to comment Share on other sites More sharing options...
Dkuzik Posted September 22, 2022 Author Share Posted September 22, 2022 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 0 Quote Link to comment Share on other sites More sharing options...
steven99 Posted September 22, 2022 Share Posted September 22, 2022 \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. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.