On one of my sites, I created a form that collects a name, email address, and description of their idea.
I limited the description characters to 500 characters, since I don’t want to read a ton, and I understood how the text appears in the text box before the user enters what they want.
Currently, the user must delete the "Description of your idea", but I want to add a placeholder class, where he removes what I wrote in the text box when they click on the text box
I looked at several sites and could not figure out how to use it. I put it in my code, but usually the class just appeared as text inside my text box.
Any help on using this class would be greatly appreciated.
Here is what I wrote
Inside header
<script language="javascript" type="text/javascript">
function limitText(limitField, limitCount, limitNum) {
if (limitField.value.length > limitNum) {
limitField.value = limitField.value.substring(0, limitNum);
} else {
limitCount.value = limitNum - limitField.value.length;
}
}
</script>
<form name="form1" method="post" action="ideas.php">
Your Name: <input type="text" name="name"><br>
Your Email: <input type="text" name="email"<br>
<textarea name="desc" cols=50 rows=10 onKeyDown="limitText(this.form.desc,this.form.countdown,500);"
onKeyUp="limitText(this.form.desc,this.form.countdown,500);">Description of your idea</textarea><br>
<font size="1">(Maximum characters: 500)<br>
You have <input readonly type="text" name="countdown" size="3" value="500"> characters left.</font>
<br>
<input type="submit" name="Submit" value="Submit!"> </form>