generated from jric11/baseProject
ChatGPT's update to harden software and run db updates.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
/* HTML maxlength counts UTF-16 units; the server counts Unicode code points. */
|
||||
(function () {
|
||||
'use strict';
|
||||
function initialize() {
|
||||
document.querySelectorAll('[data-character-limit]').forEach(function (field) {
|
||||
const limit = Number(field.dataset.characterLimit);
|
||||
function validate() {
|
||||
const tooLong = Array.from(field.value.replace(/^[ \t\n\r\0\v]+|[ \t\n\r\0\v]+$/g, '')).length > limit;
|
||||
field.setCustomValidity(tooLong ? 'Please enter ' + limit + ' characters or fewer.' : '');
|
||||
}
|
||||
field.addEventListener('input', validate);
|
||||
validate();
|
||||
});
|
||||
}
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initialize);
|
||||
else initialize();
|
||||
}());
|
||||
Reference in New Issue
Block a user