Skip to content

Instantly share code, notes, and snippets.

@dholmes
Created August 18, 2011 16:35
Show Gist options
  • Save dholmes/1154476 to your computer and use it in GitHub Desktop.
Save dholmes/1154476 to your computer and use it in GitHub Desktop.
[zf] Quick and dirty validating field
<?php
$color = new Zend_Form_Element_Text('color');
$color->AddValidator('Regex',false,array('/^\#[a-f0-9]{6}$/i'));
$color->getValidator('Regex')->setMessages( array(
Zend_Validate_Regex::NOT_MATCH =>
'\'%value%\' is not valid. Use a value in the form of #112233'
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment