I have the following javascript to determine whether a copyright is properly formatted:
var copyright = $('#copyright')
var copyright_text = copyright[0].value
if (copyright_text.length > 0) {
var containsYear = /\d{4}/.test(copyright_text);
if (containsYear == false) {
copyright.css({
'background-color': 'rgba(230, 89, 78, 0.07)',
});
copyright.parent().append(
'<div class="explanatory caution">CAUTION: Make sure this copyright contains a year.</div>'
);
};
};
How would I apply this same logic to .blur() as well as the normal page load above without copy and pasting all the code from above?
You can use
.triggerto trigger the callback after you add it: