Trying to get a class change when entering any character other than lowercase letters in a text box. However, and I am sure that there is some stupid little thing causing this, its is not showing console.log of “yo!”. Here is the javascript:
$(function(){
$("input[name='name']").keyup(function(){
var str = $(this).val();
var badChars = new RegExp("[^a-z]");
if (str.indexOf(badChars)!=-1){
console.log("yo!");
$(this).removeClass("good");
$(this).addClass("error");
}
});
});
What am I messing up?
RegExp.test()method