Skip to Content Skip to Menu

[SOLVE] REGEX password

  • chanteur94
  • chanteur94
  • OFFLINE
  • Posts: 302
  • Thanks: 13
  • Karma: 1
4 years 4 months ago #319561 by chanteur94
REGEX password was created by chanteur94
Hi

By default, I can use in the field "password" the rule 'At least 6 caracters, one uppercase, one lowercase,one special character, one digit'
It works fine.

I would like to use the same REGEX but with 8 digits.

So I use ^(?=.{8,}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?\W).*$

It works fine to, but the display of the error message if I make a mistake, is not the same with the default 6 digits.

I explain :

With the default REGEX (6 digits), if I make a mistake, and I correct them, the error message disappear
With my REGEX (8 digits), even if I correct my mistake, the error message still display.


Hope you understand my request.

Best regard

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • ONLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
4 years 4 months ago #319569 by beat
Replied by beat on topic REGEX password
Hi,

Your Regex must be PHP and Javascript-compatible.

CB uses this Regex:
Code:
/^(?=.*\d)(?=.*(\W|_))(?=.*[a-z])(?=.*[A-Z]).{6,255}$/u
Maybe simply changing the 6 with an 8 would do too ?

Also does your error come from Javascript or from PHP ?

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info
The following user(s) said Thank You: chanteur94

Please Log in or Create an account to join the conversation.

  • chanteur94
  • chanteur94
  • OFFLINE
  • Posts: 302
  • Thanks: 13
  • Karma: 1
4 years 4 months ago #319574 by chanteur94
Replied by chanteur94 on topic [SOLVE] REGEX password
Hi

With your REGEX, it works fine

I don't know if my error come from Javascript or from PHP. (it comes from CB)

Thank you.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
4 years 4 months ago #319581 by krileon
Replied by krileon on topic [SOLVE] REGEX password
Your REGEX was missing delimiters. Notice the REGEX supplied by beat leads with a / and ends with a / before the REGEX settings. I personally use RegexBuddy to help construct and test REGEX, but there's some free tools below that can be really helpful in generating valid REGEX.

regex101.com/
regexr.com/


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: chanteur94

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum