cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "bart remmerie" <>
Subject CForms-ajax : validation & on-value-changed event interference ??
Date Wed, 11 Apr 2007 21:00:09 GMT
I have a user-registration form, which checks if a username exists
using ajax (using the on-value-changed event), and displays it to the
At the same time, I wanted to add validation to the field, doing
basically the same check, when the form is submitted.

What seems to happen each time the value is changed is the following sequence:
* validation of the field is executed, followed by
* the on-change-event code

BUT, when a username exists, the following seems to occur:

* validation is executed, and returns false => username is not valid
* on-change-event is executed, but the value of the field seems to be null
* the value remains in the widget

I can imagine that due to validation, the value is reset to null (not sure)
I have the following questions:
* Is my assumption correct: is the value reset due to the failing validation ?
* Why does the value still appear in the widget (on the screen) ?
* Why is validation carried out anyway ?

Please find the relevant code snippets below from register_model.xml.
Note that isNewUserNameValid(value) refers to a flowscript function
that checks if the username is still available.

<fd:field id="j_username" required="true">
   <fd:datatype base="string"/>
   <fd:on-value-changed><!-- verify if the username is available -->
         var myValue=this.value;
         var userNameMessageWidget=widget.lookupWidget("../userNameMessage");
         if (value==null || value.length()==0){
            userNameMessageWidget.setValue('please enter a valid username');
            if (!isNewUserNameValid(value)){
               userNameMessageWidget.setValue('the username '+value+'
is already in use, please select another username or login using the
login page');
               userNameMessageWidget.setValue('this username is available');

         var success = true;
         if (!isNewUserNameValid(widget.value)){
username is currently in use", false));
            success = false;
         return success;
<fd:field id="userNameMessage" state="output">
   <fd:datatype base="string"/>

Best Regards,
Bart Remmerie

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message