开发者

How can I validate email in symfony 2.0 (form)

Could some body help with this?

For symfony 2.0 is no normal documention yet (becaus开发者_运维技巧e it is not stable)

I mean in PHP using symfony

class SignupForm extends Form {
    public $email;


    public function configure() {
        $this->add(new TextField('email', array('required' => true)));
    }
}

In this code I need add some options, to validate a email field


never used it but did find some info @ http://symfony.com/doc/2.0/reference/constraints/Email.html

properties:
    email:
        - Email: ~

a normal check with php5 would be something like this:

    if(filter_var($email, FILTER_VALIDATE_EMAIL)){
  echo "Valid email address.";
    }else {
    echo "Invalid email address.";
    }

php-4-5

    if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email)) {
    echo "Valid email address.";
    }else {
    echo "Invalid email address.";
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜