Within my JavaScript code, I have a function called using an onclick event in the HTML:
function validateTextField(field) {
if (field.value == '') {
sheet.insertRule("input:focus {background: #fc9fff;}", 1);
}
}
To test if the condition statement is working correctly, I replaced the insertRule with an alert message and found that the CSS is being applied even when the field is not empty. Are there any alternative methods I can use?