| | #1 |
| Alex the Copy Navigator War Room Member Join Date: 2007 Location: York County, Pennsylvania
Posts: 2,692
Thanks: 428
Thanked 2,006 Times in 1,212 Posts
|
Can you tell me why the value within this form input field does not clear when I click it? Here's the code... <head> <script type="text/javascript" function change() { document.getElementById("myField1").value=""; } </script> </head> <input type="text" id="myField1" name="email" value="Enter Email" style="height:45px;width:463px;font-size:14pt;" onClick="javascript:change()" /> Thanks. Alex |
| |
| | #2 |
| Active Warrior Join Date: 2014
Posts: 84
Thanks: 5
Thanked 11 Times in 10 Posts
|
Try closing the script tag <script type="text/javascript">
|
| |
| | #3 |
| Active Warrior Join Date: 2014
Posts: 84
Thanks: 5
Thanked 11 Times in 10 Posts
|
or even better try placeholder instead of value and drop that JS <input type="text" id="myField1" name="email" placeholder="Enter Email" style="height:45px;width:463px;font-size:14pt;" /> |
| |
| | #4 |
| Active Warrior Join Date: 2015 Location: Canada
Posts: 43
Thanks: 0
Thanked 7 Times in 7 Posts
|
Have a look at upgrading to HTML5 also, you can upgrade to use the email type and the required attribute: <input type="email" required name="email" placeholder="Enter Email" style="height:45px;width:463px;font-size:14pt;"> |
| | |
| |
| | #5 |
| Warrior Member Join Date: 2016 Location: United Kingdom
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
You must use the placeholder attribute for your form input elements. No need to have javascript there. I would also recommend not using inline-css, to prevent clutter. Separate concerns by creating an external stylesheet and writing the following: Code: input {
height: 45px;
width: 463px;
font-size: 14pt;
} Code: <input type="text" id="myField1" name="email" placeholder="Enter Email"> |
| | |
| |
|
| Bookmarks |
| Tags |
| called, form, html, inside, javascript, question |
| Thread Tools | Search this Thread |
| |