How can we setup a word count limit on a field?

Tom Buchanan created the topic: How can we setup a word count limit on a field?

We know how to setup a character count limit on a field using the "maxlength" additional attributes, but how can we setup a word count limit on a field?

Please advise as soon as possible.

Thank you.

#55583

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


Zhanna Khachatryan replied the topic: How can we setup a word count limit on a field?

Hi Tom,

Thanks for your inquiry.

You need to add an additional "onchange" attribute and then enter form options > Custom JavaScript and write the script to make it work.

Drop us a line if you'll have any further inquiries.


Kind regards,
Zhanna K.
Web-Dorado team

Try out our brand new plugins:

MailChimp WD
Google Analytics WD

Explore them and share your thoughts!
#55643

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


Tom Buchanan replied the topic: How can we setup a word count limit on a field?

Hi Zhanna,

Thank you for your response.

Ok, please can you give me the Custom JavaScript code to make it work?

Thank you.

#55679

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


Zhanna Khachatryan replied the topic: How can we setup a word count limit on a field?

Hi Tom,

You want it only for the text input field, right?


Kind regards,
Zhanna K.
Web-Dorado team

Try out our brand new plugins:

MailChimp WD
Google Analytics WD

Explore them and share your thoughts!
#55753

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


Tom Buchanan replied the topic: How can we setup a word count limit on a field?

Hi Zhanna,

Yes, we just want to limit the number of words which can be inserted into the field.

Thanks

#55763

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


Tom Buchanan replied the topic: How can we setup a word count limit on a field?

Can we have a response to this please?

#55911

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


Zhanna Khachatryan replied the topic: How can we setup a word count limit on a field?

Hi Tom,

In reality I was seeking for a easier way and found it. We can do this with Regular expressions option.

While creating a text input field, there is an option Validation (Regular Exp.), please enable it, under it there will appear a field Regular expression, please write the below expression there:

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


Here 10 stands for the number of words you want to limit. Please change it per your requirements.

Below you'll see a field Alert Message, here yo can write custom alert text that will appear when user exceeds the number of words.

I have also made a screenshot for you to better imagine what should go where.

Drop me a line if you'll have any further inquiries.


Kind regards,
Zhanna K.
Web-Dorado team

Try out our brand new plugins:

MailChimp WD
Google Analytics WD

Explore them and share your thoughts!
#55945
Attachments:

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


Tom Buchanan replied the topic: How can we setup a word count limit on a field?

Hi Zhanna,

Thank you for your response.

Your solution sounds good, however I don't seem to have the same options for my text input. Please see the following screenshot - prntscr.com/avfaiz

Please note I am using Joomla 3.4.8 and FormMaker 3.6.0.

Please advise.
Thanks

#55957

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


Zhanna Khachatryan replied the topic: How can we setup a word count limit on a field?

Hi Tom,

I'm sorry, this option is available for WordPress Form Maker and unfortunately not yet available for Joomla.

So, we should do it with Custom JavaScript.

For this please enter the text input field and add an additional attribute like I show in the screenshot.

After that, please enter form options JavaScript and add the below code:

// before form submit
function myfunction(elem) 
{
     
     var my_value =  jQuery(elem).val();
     if(my_value.split(" ").length > 2 ){
          alert('message');
 jQuery('.button-submit ') .attr('disabled', 'disabled');
      jQuery(elem) .effect( "shake", {}, 500 ).css("background-color","#FF8F8B").animate({backgroundColor: transparent}, {duration: 500, queue: false });
           
     } else{
  jQuery(elem).css("background-color","transparent");
 jQuery('.button-submit ') .removeAttr('disabled');
}

Please note that here

if(my_value.split(" ").length > 2 ) - 2 stand word the number of words that you want to set limit on.

alert('message') - here instead of message please write the text you want to appear in the alert window.


Kind regards,
Zhanna K.
Web-Dorado team

Try out our brand new plugins:

MailChimp WD
Google Analytics WD

Explore them and share your thoughts!
#55965
Attachments:

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


Tom Buchanan replied the topic: How can we setup a word count limit on a field?

Hi Zhanna,

Thank you for your response.

I have tried inserting the following Javascript in the Javascript Options....

// before form submit 
function myfunction(elem) 
{

var my_value = jQuery(elem).val(); 
if(my_value.split(" ").length > 400 ){ 
alert('400 words maximum.'); 
jQuery('.button-submit ') .attr('disabled', 'disabled'); 
jQuery(elem) .effect( "shake", {}, 500 ).css("background-color","#FF8F8B").animate({backgroundColor: transparent}, {duration: 500, queue: false });

} else{ 
jQuery(elem).css("background-color","transparent"); 
jQuery('.button-submit ') .removeAttr('disabled'); 
}

Please see the following screenshot of my "Additional Attributes" - prntscr.com/avhnix
As you can see, I have as follows...

Name: "onchange"
Value: "myfunction(elem)"

However the word count isn't being limited to 400 as I have specified in the Javascript code above.

Please advise how to resolve.
Thanks

Tom

#55987

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


Zhanna Khachatryan replied the topic: How can we setup a word count limit on a field?

Hi Tom,

The issue is that you haven't used the same additional attribute value, that I have used.

Please use these variables and you'll see it working.

Name: "onchange"
Value: "myfunction(this)"


Kind regards,
Zhanna K.
Web-Dorado team

Try out our brand new plugins:

MailChimp WD
Google Analytics WD

Explore them and share your thoughts!
#56167

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


Tom Buchanan replied the topic: How can we setup a word count limit on a field?

Hi Zhanna,

Thank you for your message.
Apologies for the delay in getting back to you.
By the time we looked into this issue the form was close to expiring.

However we will need this feature on a new form on our website.
Please can you provide the exact code to insert and directory to insert to?

Many Thanks

Tom

#62733

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


Zhanna Khachatryan replied the topic: How can we setup a word count limit on a field?

Hi Tom,

First of all please add an additional attribute to the field, with the below info:

Name - onchange
Value - myfunction(this)

Then please enter for options > Javascript and add the below code there:

// before form submit
function myfunction(elem) 
{
     
     var my_value =  jQuery(elem).val();
     if(my_value.split(" ").length > 2 ){
          alert('message');
 jQuery('.button-submit ') .attr('disabled', 'disabled');
      jQuery(elem) .effect( "shake", {}, 500 ).css("background-color","#FF8F8B").animate({backgroundColor: transparent}, {duration: 500, queue: false });
           
     } else{
  jQuery(elem).css("background-color","transparent");
 jQuery('.button-submit ') .removeAttr('disabled');
}


Kind regards,
Zhanna K.
Web-Dorado team

Try out our brand new plugins:

MailChimp WD
Google Analytics WD

Explore them and share your thoughts!
#62827

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


Eric replied the topic: How can we setup a word count limit on a field?

I tried this using newest version of form maker on wordpress and it didn't work, please advise - need this ASAP

#93991

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


Anoush replied the topic: How can we setup a word count limit on a field?

Dear Eric,

Thanks for getting to us!

Please note that Web-Dorado forum is closed for new posts. You can open tickets with your topic links.

Please contact us using this form. .

Do not forget to indicate the link to this forum thread in your message. Thanks! Have a good day!

#94027

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


Time to create page: 0.272 seconds
Powered by Kunena Forum

WORLD-CLASS SUPPORT

We are here for you every step of the way. Turn to our support with any questions you might have about our products and services. Our experienced customer care team is available to help you as fast as we possibly can.

Contact us