Dear Matthew,
thanks for your help.
I managed to prevent submiting form before all required fields are properly
filled.
Email:
->addElement ( 'validationTextBox', 'email', array ('required' => true,
'label' => 'Email address', 'regExp' =>
'[EMAIL PROTECTED],4}\b', 'invalidMessage' =>
'Please provide valid Email address.', 'filters' => array ('StringTrim',
'StringToLower' ), 'validators' => array ('NotEmpty', array ('StringLength',
true, array (6, 20 ) ), array ('Regex', true, array ('/\w+/i' ) ) ) ) )
(maybe someone will find this usefull)
BUT! :))
my checkboxes wont work :)
$agreements
->addElement ( 'checkbox', 'ages', array ('required' => true, 'label' =>
'I\'m Over 18 years old', 'invalidMessage' => 'You must validate that you
are over 18' ) )
->addElement ( 'checkbox', 'promotions', array ('required' => true, 'label'
=> 'I agree NOT to send any email promotions promoting this web site',
'invalidMessage' => 'You must validate that you are over 18' ) )
->addElement ( 'checkbox', 'terms', array ('required' => true, 'label' => 'I
agree to the Terms & Conditions', 'invalidMessage' => 'You must validate
that you are over 18' ) );
$form = new Zend_Dojo_Form ( );
$form->setMethod ( 'post' )->setAction ( "/signup/process" )->setName (
'signup' );
Alert you suggested me to make wont work as well :(
phtml:
<? $this->dojo()->javascriptCaptureStart() ?>
function validateForm() {
var form = dijit.byId("signup");
if (!form.validate()) {
alert("Invalid form");
return false;
}
return true;
}
<? $this->dojo()->javascriptCaptureEnd() ?>
<? $this->dojo()->onLoadCaptureStart() ?>
function () {
dojo.connect(dijit.byId("signup"), "onSubmit", "validateForm");
}
<? $this->dojo()->onLoadCaptureEnd() ?>
<div class="signupForm">
<?= $this->form ?>
</div>
Thanks,
Vladimir
--
View this message in context:
http://www.nabble.com/Zend_Dojo-Email-validation%2C-checkbox-and-Submit-dojo-form-question--please--tp19441003p19462822.html
Sent from the Zend Framework mailing list archive at Nabble.com.