最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - cakephp - what is the validation rule for email - Stack Overflow

programmeradmin0浏览0评论

I have a form in my cakephp app which requires an email address. I'm using some custom javascript validation to make sure the email address is valid and I want to mimic however cakephp decides if an email address is valid so I know it'll save ok when the form actually submits.

So at the minute I'm only checking if there's an @ symbol. What else does cakephp do to check an email address is valid?

I have a form in my cakephp app which requires an email address. I'm using some custom javascript validation to make sure the email address is valid and I want to mimic however cakephp decides if an email address is valid so I know it'll save ok when the form actually submits.

So at the minute I'm only checking if there's an @ symbol. What else does cakephp do to check an email address is valid?

Share Improve this question asked Feb 10, 2014 at 23:50 crazy sarahcrazy sarah 6314 gold badges13 silver badges29 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 2

Please read the documentation http://book.cakephp/2.0/en/models/data-validation.html#Validation::email

And take a look at the source code. All the answers are right there.

class User extends AppModel {
    public $validate = array(
        'email' => array(
            array(
                'rule' => array('email'),
                'message' => 'Please enter a valid email address',
            ),
        ),
    );
}

In your Model,put this

public $validate = array(
             //.... other validation here
        'email'=>array(
            'Valid email'=>array(
                'rule'=>array('email'),
                'message'=>'Please enter a valid email address'
            ),));

It'll automatically validate it when you submit (save)

发布评论

评论列表(0)

  1. 暂无评论