bExplosion
bExplosion

Reputation: 187

jQuery Placeholder & Master Pages

I'm using the jQuery Placeholder plugin on my forms, everything works perfectly on the asp.net page; and on my masterpage I have all the correct .ClientID settings so my jQuery Validation is works.

The issue I am having is that to initialise the placeholder script you use:

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

Is there a way for me to get this working on a masterpage, I tried calling

<%=txtFirstName.UniqueID %>.placeholder()

with no luck, is there a way to get this working?

Sorry guys I made a mistake; the placeholder is on a TextBox.

All help is greatly appreciated.

Matt

Upvotes: 0

Views: 377

Answers (4)

Stuart Wakefield
Stuart Wakefield

Reputation: 6414

I can only imagine that your ddlFirstHome.UniqueID attribute returns a string with the ID of the element you want to add a placeholder to. Something like FirstHome. So you would need to select it with jQuery...

$("#FirstHome").placeholder();

Adding in the ASP.NET placeholder you get...

$("#<%=ddlFirstHome.UniqueID %>").placeholder();

EDIT Forget the above, you should be able to run the plugin on all inputs and textareas indiscriminately. Presumably in your master page you have a html head tag or you are including it in your template somewhere. Just add...

<script type="text/javascript">
  // Run on document ready
  $(function() {
    // target all inputs and textareas with the attribute placeholder
    // and enable cross-browser placeholders
    $("input[placeholder],textarea[placeholder]").placeholder();
  });
</script>

Upvotes: 1

Anoop
Anoop

Reputation: 23208

Modified code: try this

$("#<%=ddlFirstHome.UniqueID %>").placeholder()

Upvotes: 1

xdazz
xdazz

Reputation: 160863

You should use:

$('#<%=ddlFirstHome.UniqueID %>').placeholder();

Upvotes: 0

James
James

Reputation: 82096

How about:

$("#<%= dllFirstHome.UniqueID %>").placeholder();

Upvotes: 0

Related Questions