Back to list
Views:   21.7K
Replies:  2
Archived

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" })
Vito Iacono, Sep 05, 2013
Reply 1
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.
Jack
Jack Poorte, Sep 05, 2013
Reply 2
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! 
Great.

Vito Iacono, Sep 05, 2013
Thank you Danut. I shall work towards MVVM pattern adoption. - ursri
Jun 01, 2012


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.2.2