I have a < input type=\"text\" >
(in HTML) and everytime I add a character I do a if text.length < x {...}
(in JavaScript).
The problem i
I think you have most of the research done, you only need to put all of it together:
Taking the function that your link provides:
function countSymbols(string) {
var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
return string
// Replace every surrogate pair with a BMP symbol.
.replace(regexAstralSymbols, '_')
// …and *then* get the length.
.length;
}
your if should be
if (countSymbols(document.getElementById("1").value)<16) { ...}
For example: countSymbols('