1
I have two textarea on my page to give GET the value I have in my database and I want to delete the text of the two textarea automatically put a default value there "inside".
1
I have two textarea on my page to give GET the value I have in my database and I want to delete the text of the two textarea automatically put a default value there "inside".
1
With Jquery you can do this in the event .change, this event is triggered when the value of an element is changed. In this event it can be checked whether the 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 event onpropertychange.
$('#text1').bind('input propertychange', function() {
if( $("#text1").val().length < 1){
$('#text1').val('Valor padrão');
}
});
Browser other questions tagged javascript html
You are not signed in. Login or sign up in order to post.
If it is something (only) visual you can use
placeholder='valor padrão', without the need for Javascript.– Renan Gomes