Reputation: 157
I have this code inside a form of mine:
<textarea>Your message</textarea>
The html content of the tag will be emptied on focus.
I want to run some validation on this field with jQuery. First, the value of this field should not be = "". Secondly, the content of the tag should not be = "Your message".
Anyone knows how I can archive this in the most efficient way?
Upvotes: 0
Views: 3056
Reputation: 1104
Try
$('form').submit(function(){
var form=$(this);
var text=form.find('textarea');
if(text!="" && text!="Your message"){
return true;
}else{
return false;
}
});
Upvotes: 1
Reputation: 2379
I would recommend using jQuery validation plugin which can be found at bassisance.de
Upvotes: 2