I'm trying to find if what the user typing in to an input field contain certain text - I've kinda got it works, but only working for an exact match as opposed to a partial match. If a user types anything before the text i'm matching, of course the code doesn't trigger.
What i need to do is check if the input contains @nyu.edu
at all in the input field.
$('.email').keyup(function(){
if ($(".email").val() == "@nyu.edu") {
$("p.warning").css("visibility", "visible");
}
else if ($(".email").val() != "@nyu.edu") {
$("p.warning").css("visibility", "hidden");
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…