Solved

Creating hints inside of textboxes

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

Accepted Solution

by:
myselfrandhawa earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now