JSF: Email Address Not Stripping Spaces on Validation
来源:互联网 发布:淘宝最新市值 编辑:程序博客网 时间:2024/06/14 05:23
In the following script, <f:validateRegex pattern="^[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" /> consider trailing spaces as invalid,
I have a task to make it valid, that is even there is trailing spaces, the input filed will pass the regex validation.
So I add this attribute: onchange="this.value=this.value.trim()" .The onchange fires before the validations do, so it will act as if the user did not enter any spaces at the beginning or end of the input.
The reason that I didn't modify the regex pattern because I don't want backend work. Because the input value is bound with backend bean, bean or controller need to handle stripping if regex were changed.
<!-- EMAIL AND EMAIL CONFIRM --> <h:panelGroup id="emailPanel" layout="block" styleClass="myatc-formrow-group"> <atcui:formError id="emailMessage" for="enterEmail" ajaxRendered="false" /> <atcui:formRow> <h:inputText id="enterEmail" required="true" value="#{loginSelectionBean.email}" onchange="this.value=this.value.trim()" maxlength="45" pt:placeholder="email" pt:autocapitalize="none" requiredMessage="Please enter a valid email address." validatorMessage="Please enter a valid email address. Example: yourname@domain.com"> <f:validateRegex pattern="^[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" /> </h:inputText> </atcui:formRow> <atcui:formError id="confirmEmailMessage" for="confirmEmail" ajaxRendered="false" /> <atcui:formRow> <h:inputText id="confirmEmail" required="true" value="#{loginSelectionBean.confirmEmail}" onchange="this.value=this.value.trim()" onchange="this.value=this.value.trim()" maxlength="45" pt:placeholder="reenter email" pt:autocapitalize="none" requiredMessage="Email confirmation is required." validatorMessage="Please enter a valid confirmation email address."> <f:validateRegex pattern="^[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" /> </h:inputText> </atcui:formRow> </h:panelGroup> <!-- PASSWORD AND PASSWORD CONFIRM --> </h:panelGroup>
0 0
- JSF: Email Address Not Stripping Spaces on Validation
- Email Address Validation
- 5/29工作日志-组会记录,Email address validation
- Email address validation using ASP.NET MVC data type attributes
- JSF Validation Error: Value is not valid错误
- JSF Validation Error: Value is not valid(值无效)JSF值转换无效的两个解决办法
- check MAC Address Validation
- jsf - javax.validation.ConstraintViolationException
- SMS address is email
- The Abstraction: Address Spaces(地址空间)
- charles提示Denying access from address not on ACL解决方法
- 解决:Cannot push these commits as they contain an email address marked as private on GitHub
- remote: ERROR: committer email address remote: ERROR: does not match your user account.
- This email address is not valid for use as an Apple ID.
- email address 生成图片程序
- email address 生成图片程序
- my email address for company
- Single address spaces: design flaw or feature? part1
- 常用的linux命令
- java基础之动态代理
- codeforces-445【A思维】【B并查集】
- Python使用with时本猿犯了一个错误
- SQLite数据库相关知识
- JSF: Email Address Not Stripping Spaces on Validation
- Python高阶函数--map
- Obfuscation_HDU - 2340
- 转自csdn排名第一博主 成功的背后
- 图解HashMap和HashSet的内部工作机制
- 计算几何
- Spark构建分类模型
- JAVA入门笔记2:选择结构语句
- 20161101 学习心得