<h:inputText id="email"
value="#{user.user.email}"
title="Email"
onchange="this.form.submit()"
required="true" requiredMessage="_____">
<f:validator validatorId="checkvalidemail"/>
</h:inputText>
<h:message for="email" styleClass="error"/>
validati开发者_开发知识库on:
String enteredEmail = (String)object;
Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
Matcher m = p.matcher(enteredEmail);
boolean matchFound = m.matches();
if (!matchFound) {
FacesMessage message = new FacesMessage();
message.setSummary("____");
throw new ValidatorException(message);
and css
.error {
background-image: url('includes/style/delete2.png');
text-align: left;
font-size: 36px;
}
Thank you very much Best Regards Ignacio
The <h:message>
renders a HTML <span>
whose dimensions depends on the node value. If there's nothing, then it will simply collapse and you won't see the CSS background-image
. You need to make it a block level element with a fixed size instead.
.error {
display: block;
width: 36px;
height: 36px;
background-image: url('includes/style/delete2.png') no-repeat;
}
Add if necessary float: left;
if you want to keep it on the same line.
精彩评论