【问题标题】:i want to validate the mobile number in grails and the mobile number must start with specific digit like 9我想在 grails 中验证手机号码,手机号码必须以特定数字开头,如 9
【发布时间】:2015-02-19 14:43:13
【问题描述】:

我想检查 grails 中的手机号码验证??手机号码必须以第一个特定数字 9 开头。如果它以任何其他号码开头,则用户必须收到消息以输入以 9 开​​头的号码。

【问题讨论】:

    标签: grails


    【解决方案1】:

    您可以针对此要求使用matches 约束,例如:

    class Mobi {
    
    long mobileNo
    
    static constraints = {
    mobileNo(blank:false, matches:"9[0-9]{10}")
     }
    }
    

    然后将您的消息设置为message.properties

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-14
    • 2017-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多