![]() |
Javascript called from within an HTML form question 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 |
Re: Javascript called from within an HTML form question Try closing the script tag <script type="text/javascript"> |
Re: Javascript called from within an HTML form question 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;" /> |
Re: Javascript called from within an HTML form question 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;"> |
Re: Javascript called from within an HTML form question 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 {Code: <input type="text" id="myField1" name="email" placeholder="Enter Email"> |
| All times are GMT -6. The time now is 07:13 PM. |