WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Anyone knows how to limit the textarea to 250 characters? (1 post)

  1. yahyaayob
    Member
    Posted 3 years ago #

    Hi everyone,

    Anyone knows how to limit the textarea to 250 characters?

    Currently, this is wat i did -

    function wpcf7BeforeSubmit(formData, jqForm, options) {
        //Modification
        var question = jQuery('textarea').val();
        var qLen = question.length;
        if (qLen > 250) {
            alert('Oops, your question is over the 250 character limit! Click OK to rephrase and submit.');
            return false;
        } 
    
        //End modification
        wpcf7ClearResponseOutput();
    
        jQuery('img.ajax-loader', jqForm[0]).css({ visibility: 'visible' });
    
        formData.push({name: '_wpcf7_is_ajax_call', value: 1});
    
        jQuery(jqForm[0]).append('<input type="hidden" name="_wpcf7_is_ajax_call" value="1" />');
    
        return true;
    
    }

    The problem now is that the client is still receiving test messages.

    The process should be like this - I type a message more than 250 characters and then a pop-up message will appear to warn me and ask me to rephrase the message. I click ok and now I can edit my message in the textarea.

    So the client now receives test messages still.

    Anyone can help or have another alternative solution to this? Much appreciated. =)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic