I’ve been looking everywhere for a function that would control the minimum number of words entered in the textarea and, in a case the user doesn’t put the minimum number of words (250 let’s say), an alert would appear once he tries to submit the message.
I am using this theme: http://www.elegantthemes.com/demo/?theme=AskIt
This is how the form is submitted:
<form action="<?php echo(get_permalink($post->ID)); ?>#create_new_post" method="post">
And this is the textarea code:
<textarea name="et_newpost_content" id="et_newpost_content" class="input"><?php if ( isset( $_POST['et_newpost_content'] ) ) echo esc_textarea( $_POST['et_newpost_content'] ); ?></textarea>
Modify your form tag so it reads:
then in your javascript, enter
This will prevent the form from being submitted unless the character length of the text in the text area is greater than whatever you set for minLength.
EDIT
I see I misread the question and counted characters and not words. If you need words (and props to @João) the function should read something like
The split function uses a regular expression to split the text in the textarea by whitespace characters and puts that into an array. Then you check the array’s length to see if you have enough words
EDIT 2
In a WordPress site running in noConflict mode, the snippet should look like