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

I have a form in my cakephp app which requires an email address. I'm using some custom javascript

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)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745120309a4612375.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信