这个和在MessageBean 方法里绑定一个方法是一样的效果
public void inputValueNotNullalidate(FacesContext facesContext, UIComponent uiComponent,
Object object) throws ValidatorException{
String inputValue = String.valueOf(object);
System.out.println("验证走了");
System.out.println(inputValue);
if(null == inputValue || "" ==inputValue){
throw new ValidatorException(new FacesMessage("必填项不能为空"));
}
}
这个是自己写验证,但是这个验证效果是一样的,只有带鼠标离开焦点的时候才回出发这个验证!!!
本文介绍了一个JavaScript自定义输入验证的方法实现,该方法用于确保输入字段不为空。当用户离开输入框时触发验证,若为空则抛出异常提示必填。
3076

被折叠的 条评论
为什么被折叠?



