Webresource development with HTML5 features}–How to show default text in controls on your HTML webresources

Wanted to share this really cool stuff with fellow Dynamics CRM consultants who might not be aware of this html5 feature.


We had a webresource and where we had multiple input controls. Our client wanted that these input controls should show some default text to make the user understand the type of input the application is expecting in the input control.

For e.g – suppose we have a text box for email. We can show some default text like ‘some@example.com’ to highlight the format of the input to the end user. Typically in UI, it should render something like below.


If you try to implement this custom you would need to do the following things.

  • Create a common library to show the suggestive text
  • When the user starts to type in, the default text should go away
  • The default text should not be considered during mandatory field validation
  • If the user deleted the text, the default text should re-appear
  • Last but not the least, separate CSS styles for the default text and text entered by the user.


What if I say that you do not need to do all this if HTML5. All you need to do is set the value of a new attribute in HTML5 called placeholder. The code for the above screenshot would be the one below.

<input type="email" name="email" placeholder="someone@example.com">
<input type="text" name="first_name" placeholder="First name">

The good thing is that the browser controls everything for you. If you are wondering what is input type = ‘email’ in the HTML above, well that is another new stuff in HTML5. To know more about that, you can refer to my following blog post.


So next time somebody asks you to develop a webresource, show off some your HTML5 skills as well Smile


Hope this helps!

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 12 years of experience in Microsoft .NET Technologies and 9 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s