![]() ![]() |
I am new to JavaScript. I have a Description field on a form. I need some GreaseMonkey code to check if the field is empty, and if so, insert a template into the field. If it's not empty, I want to leave it alone. Is there code available to do this? Thank you. |
![]() ![]() |
Generally speaking, you should be able to do this. Note that you need a way to identify the particular form field, which depends on your particular page. if (myFormField.value.length == 0){
myFormField.value = "some big long chunk of text";
}
|
![]() ![]() |
Thanks for your help. What I really want to do is -- See if this field is empty: <textarea></textarea>
If it is, I want to insert some text in it:
<textarea>Monkey Text here
</textarea> |
![]() ![]() |
I think part of it got cut off. It should be: " <textarea>Monkey Text here
"
</textarea> |
![]() ![]() |
Does this work? if (myTextarea.textLength == 0){
myTextarea.textContent = "some big long chunk of text";
}
Note: there isn't enough information in your posts to set myTextarea. |


