Skip to content

验证是否是正则表达式,没有效果。 #49

@HappyYawen

Description

@HappyYawen

{type:'regexp',required:true,message: '请输入正则表达式', trigger: 'blur'}
这样写没有验证效果。请问应该怎么使用?

Activity

jruif

jruif commented on Jun 27, 2017

@jruif

Must be an instance of RegExp or a string that does not generate an exception when creating a new RegExp

应该是缺少Pattern,试试这样:

{type:'regexp',required:true,message: '请输入正则表达式', trigger: 'blur', pattern: /\w+/g}
chou0728

chou0728 commented on Aug 21, 2018

@chou0728

@jruif
type要改成 string才有效果
{type:'string',required:true,message: '请输入正则表达式', trigger: 'blur', pattern: /\w+/g}

xxssww0258

xxssww0258 commented on Dec 17, 2018

@xxssww0258

[{ pattern: /^\d+$/, required: true, message: 'pattern这个字段就够了' }]

ohroy

ohroy commented on Sep 2, 2023

@ohroy

望文生义了。。原来 regexp是验证输入的内容是否是正则表达式

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jruif@ohroy@chou0728@HappyYawen@xxssww0258

        Issue actions

          验证是否是正则表达式,没有效果。 · Issue #49 · yiminghe/async-validator