Reputation: 351
If input text field contains "@twitter.com", would like to append text to div
.
Currently have the following but only works when [email protected]
, any suggestions?
var test = jQuery('input[name$="user_email"]').val();
if(test == "@twitter.com"){
jQuery(".iump-clear").append('<div>Please update your email address</div>');
}
<input type="text" name="user_email" value="[email protected]">
<div class="iump-clear"></div>
Upvotes: 2
Views: 8051
Reputation: 5953
You should check if @twitter.com is contained in input, you can use .indexOf()
for that
var test = jQuery('input[name$="user_email"]').val();
if(test.indexOf("@twitter.com")>-1){
jQuery(".iump-clear").append('<div>Please update your email address</div>');
}
<input type="text" name="user_email" value="[email protected]">
<div class="iump-clear"></div>
Upvotes: 2