Skip Navigation

[Resolved] Min and max characters/words

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 24 replies, has 2 voices.

Last updated by Nicholas 6 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#541617

Hello I would like to set a min and max character or word count for all CRED multiple lines text fields.

For example min of 50 words and max of 200 words.

Is this currently possible?

#541835

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

There is no such native feature available to set min and max character or works but you can use custom javascript/jQuery code to achieve your goal.

Please refer to the following ticket where I shared kind of solution:
=> https://toolset.com/forums/topic/limit-characters-in-multiple-custom-fields-in-a-cred-form/#post-349131

#541896

Thank you. I'll check this out and will let you know how that goes.

#541995

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok fine - thank you.

#542370
#542529

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - sure.

1)
Could you please share problem URL.

2)
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#542895

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please share the link of the page where you added CRED form Create Product

#543332

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - wp-admin access details you send to me is not working at this end.

Could you please resend it to me.

#543370

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No - its still not working. Could you please check that username and password are same.

I have set the next reply to private which means only you and I have access to it.

#543397

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now. CRED form element classes has been changed with new release and I've adjusted the code as given under and its working.

Please clear your browser cache before you make a test.

(function($) {
    $.fn.extend( {
        limiter: function(limit, field) {
          field = field.replace('wpcf-','');
            $("div.form-group p.counter-"+field).hide();
            $(this).on("keyup focus", function() {
                $("div.form-group p.counter-"+field).show(); 
                setCount(this, field);
              });
            $(this).on("blur", function() {
              $("div.form-group p.counter-"+field).hide();
            });
            function setCount(src,field) {
               var chars = src.value.length;
              //console.log(src);
               if (chars > limit) {
                   src.value = src.value.substr(0, limit);
                   chars = limit;
               }
               remainder = limit - chars;
               field = field.replace('wpcf-','');
              $("div.form-group p.counter-"+field+" span.remainder").html(remainder);
           }
          setCount($(this)[0], field);
            
        }
    });
            
})(jQuery);

jQuery(document).ready(function($){
 
jQuery(document).on( 'cred_form_ready', function() {  
  
$("input[name='wpcf-artist-1']").limiter(10, 'wpcf-artist-1');
 
}); 
  
});

#543444

Hello thank you. What classes were changed with the update?

Unfortunately it doesn't work.

I can still add more than 10 characters to the wpcf-artist-1 field

#543448

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - you can compare the current solution and the old solution here:
=> https://toolset.com/forums/topic/limit-characters-in-multiple-custom-fields-in-a-cred-form/#post-349131

#543457

Thanks why doesn't the new solution work then you visit hidden link

#543459

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What you mean - go to the URL: hidden link

Try to add something to Artist 1 field and number count will be display.

#543566

Hello.
It works, however when I refresh the page or leave the page and then go back it stops working. I have to clear the cookies in order to have it work again. This is very strange. This happens to all of my custom jQuery code in CRED.

It works fine inside of CT and Views, even after I refresh the page.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.