Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 518
Kannan Arumugam Avatar asked Nov 26 '13 05:11

Kannan Arumugam


People also ask

How do you insert a placeholder in text field?

The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.

What is placeholder in text field?

Placeholder text, located inside a form field, is an additional hint, description, or example of the information required for a particular field. These hints typically disappear when the user types in the field.

How do you put a placeholder in HTML?

If you want to set a hint for text area or input field, then use the HTML placeholder attribute. The hint is the expected value, which gets displayed before the user enters a value, for example, name, details, etc.

What is placeholder tag?

The placeholder attribute specifies a short hint that describes the expected value of a input field / textarea. The short hint is displayed in the field before the user enters a value.


2 Answers

Use jQuery attr like below:

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

JavaScript code:

$(function() {
    $("#abc").attr("placeholder", "some text");
});
like image 190
rajesh kakawat Avatar answered Oct 10 '22 16:10

rajesh kakawat


Just replace:

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

With:

<input type="text" name="property" class="form-control" placeholder="some text"
                             │
                             └─── Form property ────┐
                                                    │
       value="<bean:write name="name" property="property" />" />
                                  │                
               Name of form-bean ─┘                

The value of the attribute name must match the property of your form to trip in the request.

like image 42
Paul Vargas Avatar answered Oct 10 '22 17:10

Paul Vargas