I am not sure why you want to do it on client and not in the bean itself..
But in jsf you can use Converter to convert you input.. Look at this example.
It is very easy to do
http://www.mkyong.com/jsf2/custom-converter-in-jsf-2-0/
I took the important things here..
First thing is the page..
<h:inputText id="bookmarkURL" value="#{user.bookmarkURL}"
size="20" required="true" label="Bookmark URL">
<f:converter converterId="com.mkyong.URLConverter" />
</h:inputText>
Than you need to build the converter
@FacesConverter("com.mkyong.URLConverter")
public class URLConverter implements Converter{
@Override
public Object getAsObject(FacesContext context, UIComponent component,
String value) {
String HTTP = "http://";
StringBuilder url = new StringBuilder();
//if not start with http://, then add it
if(!value.startsWith(HTTP, 0)){
url.append(HTTP);
}
url.append(value);
//use Apache common URL validator to validate URL
UrlValidator urlValidator = new UrlValidator();
//if URL is invalid
if(!urlValidator.isValid(url.toString())){
FacesMessage msg =
new FacesMessage("URL Conversion error.",
"Invalid URL format.");
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(msg);
}
URLBookmark urlBookmark = new URLBookmark(url.toString());
return urlBookmark;
}
@Override
public String getAsString(FacesContext context, UIComponent component,
Object value) {
return value.toString();
}
}
Hope that helps..