Here's a basic phone number regex sample for a standard North American telephone number e.g. 123-456-7890
Key point is to use start/end pattern indicators ^ and $ - otherwise 123-456-78901234 etc. will also match!
<field name="person.phone">
<field-validator type="required" circuit="true">
<message>${getText("error.phone.required")}</message>
</field-validator>
<field-validator type="regex">
<param name="expression"><![CDATA[^[\d]{3}-[\d]{3}-[\d]{4}$]]></param>
<message>${getText("error.phone.format")}</message>
</field-validator>
</field>

0 comments:
Post a Comment