Skip to Content Skip to Menu

[SOLVED] Validate maximum words restriction for text area

  • BuyRat
  • BuyRat
  • OFFLINE
  • Posts: 42
  • Thanks: 1
  • Karma: 0
11 years 9 months ago - 11 years 8 months ago #209543 by BuyRat
I have a text area on a profile that I want to restrict to 150 words.

In order to keep within the rest of the form validation, I decided to use the Custom Regular Expression provided on CB fields.

My expressions is:
^(?:\b\w+\b[\s\r\n]*){1,150}$

I have also tried simpler expressions but these don't seem to validate either.

So I've set the field to validate browser side but the expression never seems to make it to the client side.

Is this a bug or am I missing something?

Cheers,
Last edit: 11 years 8 months ago by krileon.

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 47949
  • Thanks: 8170
  • Karma: 1434
11 years 9 months ago #209559 by krileon
You're missing a delimiter. Try the below.

/^(?:\b\w+\b[\s\r\n]*){1,150}$/

You can find more information on REGEX usage below.

www.regular-expressions.info/


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.

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

  • BuyRat
  • BuyRat
  • OFFLINE
  • Posts: 42
  • Thanks: 1
  • Karma: 0
11 years 9 months ago #209634 by BuyRat
Hi Kyle,

Ok, cheers for the link.

This is so bizarre, is there any chance that the reg exp validation only works with input texts? And not text areas?

I have a textarea, I add the Custom Reg Exp and save, the output to the form is now an input text, remove the reg exp and the output to the form is back to textarea.

Well weird. Is it being rewritten when the validation is added?

Cheers,

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 47949
  • Thanks: 8170
  • Karma: 1434
11 years 9 months ago - 11 years 9 months ago #209717 by krileon
It should work fine with any field that supports custom validation. Ensure debug mode and maximum error reporting are enabled so you can debug if something went wrong. Also review browser error log while using the field to see if a JS error occurred during the JS validation.

As for the textarea input changing to a text input this is a known bug. Please see the below bug ticket.

forge.joomlapolis.com/issues/3599


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.
Last edit: 11 years 9 months ago by krileon.

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

  • BuyRat
  • BuyRat
  • OFFLINE
  • Posts: 42
  • Thanks: 1
  • Karma: 0
11 years 8 months ago #210384 by BuyRat
Patch applied and works thanks

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

Moderators: beatnantkrileon
Powered by Kunena Forum