I have two textarea
on my page to give GET to the value I have in my database and I want to delete the text of the two textarea
automatically set a default value there " inside. "
I have two textarea
on my page to give GET to the value I have in my database and I want to delete the text of the two textarea
automatically set a default value there " inside. "
With JQuery you can do this in the .change
event, this event fires when the value of an element changes . In this event it can be checked whether textarea
is empty, if it is, we put a default value.
$('#text1').change(function(){
if( $("#text1").val().length < 1){
$('#text1').val('Valor padrão');
}
});
For versions prior to IE9 this can be done through the onpropertychange
.
$('#text1').bind('input propertychange', function() {
if( $("#text1").val().length < 1){
$('#text1').val('Valor padrão');
}
});