-- vladimirn <[EMAIL PROTECTED]> wrote
(on Thursday, 11 September 2008, 02:52 PM -0700):
> I've attached file with my signupController.php because its to long to be
> posted here. http://www.nabble.com/file/p19441003/signupController.php.txt
> signupController.php.txt
> Its .txt but you can see whats inside.
>
>
> I dont know how to do next things:
> 1. All fields in my form are required. But if you hit Submit button, all
> validation are some kind a avoided and i am redirected to my form action
> (signup/process). How to prevent form to do this?
You need to bind to the onSubmit event of your form, and validate in
your callback. One way to do this is as follows, from your view script:
<? $this->dojo()->javascriptCaptureStart() ?>
function validateForm() {
var form = dijit.byId("<formId>");
if (!form.validate()) {
alert("Invalid form");
return false;
}
return true;
}
<? $this->dojo()->javascriptCaptureEnd() ?>
<? $this->dojo()->onLoadCaptureStart() ?>
function () {
dojo.connect(dijit.byId("<formId>"), "onSubmit", "validateForm");
}
<? $this->dojo()->onLoadCaptureEnd() ?>
What the above does is connect the onSubmit event to the form, which
then executes the validateForm() function; if this returns false,
submission is halted, and, in this case, an alert raised. You could also
popup a dialog box or some other notification.
> 2. I also have a 3 checkbox. All 3 must be checked to procced. But form
> procced no matter what.
The above should also correct this.
> 3. Is there any way to validate a field if i need that this field have a
> valid URL address?
Google for a good URL regular expression, and add it to your element as
the "regExp" option. Make sure it doesn't contain boundaries (i.e., the
"/^\d+$/" you'd pass to preg_match() would become "^\d+$" for dojo).
> 4. Is it possible to validate Email address with Zend_Dojo_Form?
Yes. Again, google for a reasonable email regexp, and add it as the
regExp option to your element.
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/