Add Listing Page – Minimum Words

This topic contains 8 replies, has 4 voices, and was last updated by  Neil Hall 6 years, 10 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #385242

    Neil Hall
    Buyer
    Post count: 83

    Hi

    Does anyone know if there is a way of setting a minimum number of words or characters on the Description box on the Add Listing Page?

    I’m trying to stop users just writing a couple of words about a listing.

    Best Regards
    Neil

    #385243

    Kor
    Moderator
    Post count: 16516

    Hi there,

    Could you try the code on this page and see if it helps? https://wpgeodirectory.com/support/topic/listings/#post-261957

    Thanks

    #385261

    Neil Hall
    Buyer
    Post count: 83

    Hi Kor

    Thank you for the tip, but I’m not sure where that code needs to be inserted. Could you give me some pointers?

    Best Regards
    Neil

    #385295

    Paolo
    Site Admin
    Post count: 31206

    Please try to copy and paste that in Design > Scripts > Footer Scripts.

    Let us know how it goes,

    Thanks

    #385470

    Neil Hall
    Buyer
    Post count: 83

    Hi Paolo

    It does work in Chrome and Firefox, but I needed to enclose it with script

    
    
    <script>if (jQuery('textarea#post_desc').length ) {
    jQuery('textarea#post_desc').attr('minlength', "100");
    } </script>

    For some reason it does not seem to work in Internet Explorer, Safari

    Best Regards
    Neil

    #385508

    Kor
    Moderator
    Post count: 16516

    Hi Neil,

    Please share WP temp admin access to your site so we can take a better look. You can post the details here using the private reply option below.

    #385518

    Neil Hall
    Buyer
    Post count: 83
    This reply has been marked as private.
    #385621

    Kiran
    Moderator
    Post count: 7069

    Hi Neil,

    Pattern validation does not supported by few version of Safari & IE.
    I am providing snippet code this will alert user if description length characters are less then required.
    To prevent user submit the form with description length less required, you need some custom code.

    
    
    <script>
    jQuery(function() {
        if (jQuery('#propertyform textarea#post_desc').length ) {
            var minLength = 100;
            jQuery('textarea#post_desc').attr('minlength', minLength);
           
            jQuery('#propertyform textarea#post_desc').blur(function() {
                var content = jQuery(this).val();
                var regx = /(<([^>]+)>)/ig;
                plaintext = content.replace(regx, "");
                if (plaintext.length < minLength) { 
                    alert('For description you must use atleast ' + minLength + ' characters.');
                }
            });
        }
    });
    </script>

    Thanks,
    Kiran

    #385640

    Neil Hall
    Buyer
    Post count: 83

    Hi Kiran

    Many thanks for your help. That does submit a warning on the other browsers. I’ll see what I can come u with to stop it submitting the form.

    Best Regards
    Neil

Viewing 9 posts - 1 through 9 (of 9 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket