use your own validator (or use an existing) and call validate <fd:field id="density" required="true"> ... <fd:validation> <fd:javascript> var value = widget.value; if (value <=0 || value >= 500) { var i18nkey = 'your.key'; var error = new Packages.org.apache.cocoon.forms.validation.ValidationError( new Packages.org.apache.cocoon.forms.util.I18nMessage(i18nkey) ); // widget should be ValidationErrorAware widget.setValidationError(error); return false; } return true; </fd:javascript> </fd:validation> <fd:on-value-changed> <javascript> if (event.source.validate()) { // your action } <javascript> <fd:on-value-changed>
... Am 08.02.2010 00:14, schrieb Maria Grigorieva: > Hello, dear mailing-list ) > > Please help if it's possible: I have a form-model with widgets and the > values of the fields > > passes to the database "on-value-changed" action (I haven't any "Submit" > buttons at all) > > And for each field I have the validation rules: > > <fd:field id="density" required="true"> > <fd:label>Density</fd:label> > <fd:datatype base="float"> > <fd:convertor type="plain" /> > </fd:datatype> > <fd:validation> > <fd:range min="0" max="5000"> > <fd:failmessage>ERROR!!!</fd:failmessage> > </fd:range> > </fd:validation> > <fd:on-value-changed> > <javascript> > var value = event.source.value; > var form = event.source.form; > var id = new > java.lang.Integer(form.getAttribute("id").intValue()); > matmodel.setR0(id,value); > </javascript> > </fd:on-value-changed> > </fd:field> > > Please, help! How can I use the validation rules to show the message to the > user on-value-changed action ??? > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org