How can I put a placeholder in a struts textfield tag?

Kannan Arumugam picture Kannan Arumugam · Nov 26, 2013 · Viewed 17.5k times · Source

i got error because am using placeholder attribute in struts tags....

<html:text property="name" styleClass="form-control" placeholder="some text"/>

how can resolve the problem,pls help me.

Thanks in Advance.

Answer

rajesh kakawat picture rajesh kakawat · Nov 26, 2013

Use jQuery attr like below:

<html:text property="name" styleClass="form-control" styleId="abc" />

JavaScript code:

$(function() {
    $("#abc").attr("placeholder", "some text");
});