Home  /  Questions  /  Question

60   95.3
Sep 05, 2013

Placeholder use with Html.TextBoxFor

Hi guys,

I'm testing Spark 4.5 solution.
I noticed that when I load SignUp.cshtml form I don't see the placeholder text. Why?

The code is as follows: 

@Html.TextBoxFor(m => m.Email, new { placeholder = "Email" })

60   95.3
Sep 05, 2013
To answer my own question, here is what I did:  

I added  the jquery.placeholder.js plugin and  this code to app.js

$(function () {
    $('input, textarea').placeholder();

And now I can see placeholders on the input boxes! 

508   99.9
Sep 05, 2013
Hello Vito:

I assume you're using an older browser, such as IE 9 or below.  They do not support the placeholder attribute.
You did the right thing by including jquery.placeholder.js to get the effect. 
BTW: here is a link of all browsers that support placeholder:  http://caniuse.com/input-placeholder

Hope this helps.