I am trying to get a result of how many matches a specific word comes back in a textfield on keyup on an input field. So far I've managed to log a success message if the input matches a word in the textfield. Does someone know how I can check how many times this word is counted in the textfield?
This is what i got so far
var keyWordNL = $('input[name*="keyword-nl_NL"]');
keyWordNL.on('keyup', function(){
var keyWordNL = $('input[name*="keyword-nl_NL"]').val();
var editor2 = $('#introduction-nl_NL').val();
if(editor2.match(keyWordNL)) {
console.log('success');
} else {
console.log('fail');
}
});