javascript - don't want to submit with prefilled value textarea; I have a required validation for text area but is not caught either -


i have textarea populated text , if click on type nothing when leave default pre-filled text populated again; don't want allow submission pre-filled text form; how can handle issue?

my code:

jquery(document).ready(function($) {     $("textarea").val("please enter email content here...");    $("textarea").focusout(function() {         if ($(this).val() === "") {             $(this).val("please enter email content here...");         }     });     $("textarea").focus(function() {         if ($(this).val() === "please enter email content here...") {             $(this).val("");         }     }); }); 

by doing:

<textarea placeholder="default text here"></textarea> 

otherwise, if need support oldies try store def. text variable , on submit check submitted value default.

http://jsbin.com/unuqes/1/edit

jquery(function($) {    var $txta = $("textarea");   var emaildef = "please enter email content here...";    $txta.val(emaildef);    $txta.focusout(function() {      if ($.trim(this.value) === "") {          this.value = emaildef;      }   });    $txta.focus(function() {      if( this.value === emaildef ) {          this.value="";      }   });    $('form').submit(function(){     var txtaval = $txta[0].value;     if(txtaval==emaildef || !$.trim(txtaval)){       alert("missing email!");       return false;     }   });  }); 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -