Solved

Creating hints inside of textboxes

Posted on 2013-06-26
1
235 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ColdFusion Web Service/WSDL Connection Issue 2 111
cfchart display 12 104
Query help 4 81
Coldfusion: Two dynamic depending drop down 12 34
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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