当用户名不符合模式时显示错误

时间:2017-04-14 13:12:36

标签: angularjs regex html5 symfony

我正在使用symfony,我想在用户名不符合模式时显示错误,我该怎么做?

{{ form_widget(form.username, {'attr':{'pattern': '[a-zA-Z]*'} }) }}

1 个答案:

答案 0 :(得分:0)

尝试将Assert添加到实体类中的属性中。

请查看Asserts:http://symfony.com/doc/current/validation.html

这个正则表达式:http://symfony.com/doc/current/reference/constraints/Regex.html