Created
November 14, 2019 23:46
-
-
Save Galibri/39d7f69b0c1b343a44c99d3428036662 to your computer and use it in GitHub Desktop.
prevent excerpt typing after 115 characters
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
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