Skip to content

Instantly share code, notes, and snippets.

@Galibri
Created November 14, 2019 23:46
Show Gist options
  • Save Galibri/39d7f69b0c1b343a44c99d3428036662 to your computer and use it in GitHub Desktop.
Save Galibri/39d7f69b0c1b343a44c99d3428036662 to your computer and use it in GitHub Desktop.
prevent excerpt typing after 115 characters
jQuery(document).ready(function($) {
var max = 115;
$('#excerpt').keydown(function(e) {
if(e.which == 8) {
return;
}
if (e.target.value.length == max) {
e.preventDefault();
} else if (e.target.value.length > max) {
// Maximum exceeded
e.target.value = this.value.substring(0, max);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment