<?php
	require_once( $GLOBALS["site_root"] . "/includes/widgets/FrontendTextbox.inc.php" );

	class RegistrationEmail extends FrontendTextbox {
		protected $bInvalid = true;

		public function isEmailValid() {
			return fo3_is_email_valid( $this->sValue );
		}

		public function render() {
			if ($this->sRendered) return $this->sRendered;
			// $this->setMandatory( true );
			$this->setAttribute( "onchange" , sprintf( "RegistrationEmailChanged( '%s' );" , $this->sId ) );
			$cls = $this->getAttribute( "class" );
			$cls.=($this->isEmailValid()) ? "" : " invalid";
			$this->setAttribute( "class" , $cls );
			return parent::render();
		}
	}
?>
