Satheesh
Satheesh

Reputation: 833

How to use html5 form validation properties using struts2 UI tags

I want to use HTML5 form validations like 'required', in struts2 UI tag . I also have checked struts2 core jar file which shows that dynamic attribute is true for s:textbox. but if i use like <S:textbox name="username" required>, it is throwing error.

Please help

Upvotes: 1

Views: 1370

Answers (3)

user2324379
user2324379

Reputation: 1

This is the only way I have made it work in IE FF and Chrome

<input type="text" name="u.lName" required value='<s:property value="u.lName"'/>'/>

Upvotes: 0

udit mittal
udit mittal

Reputation: 537

Try like this:

<s:textbox name="username" required="required" />

Works perfectly in my case.

You can also use other html5 attributes in a similar way. eg. placeholder="placeholder value" , etc.

Upvotes: 1

Quaternion
Quaternion

Reputation: 10458

The attributes must have a value. So required will not work but required="" will not cause an issue.

Upvotes: 0

Related Questions