Created
July 26, 2019 13:25
-
-
Save femiyb/b142955f46703e7fdc7850fea969fc76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function limit_text_area() | |
{ | |
echo | |
" | |
<script> | |
jQuery(document).ready(function() { | |
jQuery('#company_info').on('keyup', function() { | |
var words = this.value.match(/\S+/g).length; | |
if (words > 500) { | |
// Split the string on first 500 words and rejoin on spaces | |
var trimmed = jQuery(this).val().split(/\s+/, 500).join(' '); | |
// Add a space at the end to keep new typing making new words | |
jQuery(this).val(trimmed + ' '); | |
} | |
else { | |
jQuery('#display_count').text(words); | |
jQuery('#word_left').text(500-words); | |
} | |
}); | |
}); | |
</script> | |
"; | |
} | |
add_action('pmpro_checkout_before_submit_button', 'limit_text_area'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment