Basically, I have the labels of the fields inside the input boxes and use onblur and onclick to clear the values etc. I also have some javascript to make sure the required files aren't submitted as the label e.g. first name contains the label First Name*
and I don't want it submitted as First Name*
.
Where I'm struggling is with the comments box. It isn't a required field so I don't want an alert to pop up, I just want the javascript to change the value to either blank or n/a if it's left as 'comments'. Here is the javascript code I am using to try and achieve this:
var comments=document.getElementById('comments').value;
if (comments=="comments")
{
document.getElementById('comments').value="n/a";
}
i think your comment field is a textarea.... use
document.getElementById('comments').innerText
instead
document.getElementById('comments').value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With