I wrote a function in which I pass, mainly, a regex and an error message. What I'd like to achieve is that the browser reads the HTML code inside the Javascript code as HTML, not as a string. I've read many posts here on Stack but people seem to have exactly the opposite problem.
oneRegex(/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{8,}$/, inputValue, 'Password must contain, at least:<br> <ul><li>one number</li> <li>one capital letter</li> <li>one lower case letter</li> <li>8 carachters long</li></ul><br> i.e: passWord3', inputID);
In this case I'd like a result like:
Password must contain, at least:
- one number
- one capital letter
- one lower case letter
- 8 carachters long
Javascript functions
function addErr(errMsg, inputID) {
$('#subButton').prop('disabled', true);
$('#err' + inputID).fadeIn(500).text(errMsg);
$('#err' + inputID).css('background-color', '#E3BFC0');
$('#' + inputID).css('background-color', '#E3BFC0');
}
function removeErr(inputID) {
$('#subButton').prop('disabled', false);
$('#err' + inputID).fadeOut(500);
$('#' + inputID).css('background-color', 'inherit');
}
function oneRegex (regex, inputValue, errMsg, inputID) {
if (!regex.test(inputValue)) {
addErr(errMsg, inputID);
}
else {
removeErr(inputID);
}
}
.html()instead of.text()then?