Reputation: 1417
I am trying to check inside textarea if there is nothing typed or default value exist with this code:
if ($("#ipt-content").val() == '' && $("#ipt-content").val() == defaultValue) {
$("#ipt-content").addClass("ipt-error");
valid = false;
emptyFields = true;
} else {
$("#ipt-content").removeClass("ipt-error");
}
Unfortunately the code doesn't work. Can you please help me guys?
Upvotes: 1
Views: 64
Reputation: 4239
If your default value is line and condition required || ( logical or ) then change your code as below :
var defaultValue="line";
if ($("#ipt-content").val() == '' || $("#ipt-content").val() == defaultValue) {
$("#ipt-content").addClass("ipt-error");
valid = false;
emptyFields = true;
} else {
$("#ipt-content").removeClass("ipt-error");
}
Upvotes: 2