views:

18

answers:

1

Hello,

I am using Dojo ValidationTextBox through Zend Framework in the following way:

$form->addElement('ValidationTextBox', 'procedureName', array(
    'label' => _('Procedure Name'),
    'value' => $alarm->procedureName,
    'attribs' => array(
        'required' => true,
        'invalidMessage' => 'Required!'
    )
));

Likewise, my form validation is set up in this way:

if (formWidget.isValid()) {
    return true;
} else {
    alert('Invalid form.');
    return false;
}

Form validation will prevent the form from submitting if "procedureName" text box is blank, but Dojo will not mark the form element as invalid, nor display the "Required!" message. In fact, it will mark the form element only if I click it previously (but still, will not display the invalid message).

How can I reconstruct the behavior from this page, where you can click the submit button without clicking on any of required fields previously, and Dojo will mark all required fields?

Thanks.

A: 

The error was that I should've used formWidget.validate(), instead of formWidget.isValid().

Dario