Solved

Creating hints inside of textboxes

Posted on 2013-06-26
1
239 Views
Last Modified: 2013-09-20
Hi,

I am looking to create text formfield hints within these form fields that disappear when a user clicks inside the formfield to add their data for submission.

For example, I have a form with a textfield for a user to enter their firstname. I would like to have the word 'Enter Firstname' inside the text field but have it disappear when the user clicks into the field to enter their first name. However, as I need to verify that the user has indeed entered some data, if the user submits the form without actually entering any firstname data, the form would be 'returned' to the page with an error message. How do I create this hint within the form text field and 'strip' it way during form submission so my form validation would still work?

Thank you so much for helping me with this issue that has been haunting me for so long.
0
Comment
Question by:CFbubu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
Gurpreet Singh Randhawa earned 500 total points
ID: 39280750
for modern browsers you can always use placeholder [html5] element which will always work.

For IR you can use the Jquery Placeholder component.

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
 <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
 <![endif]-->

<script src="assets/js/placeholder.min.js" type="text/javascript"></script>

with jquery you can do it like this

<script>
$(function() { $('input, textarea').placeholder();
});
</script>
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question