The idea is not to enter more than 10 characters. Crtl + V is failing.
Example:
Follow JS code:
$(document).ready(function () {
$('#summernote').summernote({
toolbar: [
['style', ['bold', 'italic', 'underline', 'clear']]
],
callbacks: {
onKeydown: function (e) {
var t = e.currentTarget.innerText;
if (t.trim().length >= 10) {
//delete key
if (e.keyCode != 8)
e.preventDefault();
}
},
onKeyup: function (e) {
var t = e.currentTarget.innerText;
$('#maxContentPost').text(10 - t.trim().length);
},
onPaste: function (e) {
var t = e.currentTarget.innerText;
var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');
e.preventDefault();
var all = t + bufferText;
document.execCommand('insertText', false, all.trim().substring(0, 10));
$('#maxContentPost').text(10 - t.length);
}
}
});
});
Or if you prefer JSFiddle: link
Any solution?