You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by TNO <tn...@free.fr> on 2011/04/10 17:31:41 UTC

5.1 : Dynamic add (and remove) JS taspestry validator

Hi everybody,

I try to do dynamic cross validation on two fields.
I have a grid into a form. On each row, I have a select field (OK and 
KO) and a textarea commentary.
When the user select KO, commentary is enabled and his value is required.
When the user select OK, commentary is disabled and no value is required.


My JS code :

function setReadOnly(selectValue, id)
{

     var myId = [id + 'C'];

     if (selectValue=='KO') {
         myId.each(function(item) {
             var myId = $(item);
             if (myId != null) {
               myId.removeAttribute('readOnly');
               Tapestry.Validator.required(myId, 'Please explain');
             }
         });
     } else {
         myId.each(function(item) {
             var myId = $(item);
             if (myId != null) {
               myId.clear();
               myId.setAttribute('readOnly', 'true');
               myId.getFieldEventManager().removeDecorations();
               myId.getFieldEventManager().requiredCheck = null;


             }
         });

     }
}


It seems working but when I select KO, fill commentary, submit then 
select OK and submit, the submit is good but the ErrorPopup appears 
without message (only the red cross)

Two questions :
1. Did I miss something ?
2. Is there a better way to do it ?

Thanks in advance, Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: 5.1 : Dynamic add (and remove) JS taspestry validator

Posted by TNO <tn...@free.fr>.
Nobody...

Le 10/04/2011 17:31, TNO a écrit :
> Hi everybody,
>
> I try to do dynamic cross validation on two fields.
> I have a grid into a form. On each row, I have a select field (OK and 
> KO) and a textarea commentary.
> When the user select KO, commentary is enabled and his value is required.
> When the user select OK, commentary is disabled and no value is required.
>
>
> My JS code :
>
> function setReadOnly(selectValue, id)
> {
>
>     var myId = [id + 'C'];
>
>     if (selectValue=='KO') {
>         myId.each(function(item) {
>             var myId = $(item);
>             if (myId != null) {
>               myId.removeAttribute('readOnly');
>               Tapestry.Validator.required(myId, 'Please explain');
>             }
>         });
>     } else {
>         myId.each(function(item) {
>             var myId = $(item);
>             if (myId != null) {
>               myId.clear();
>               myId.setAttribute('readOnly', 'true');
>               myId.getFieldEventManager().removeDecorations();
>               myId.getFieldEventManager().requiredCheck = null;
>
>
>             }
>         });
>
>     }
> }
>
>
> It seems working but when I select KO, fill commentary, submit then 
> select OK and submit, the submit is good but the ErrorPopup appears 
> without message (only the red cross)
>
> Two questions :
> 1. Did I miss something ?
> 2. Is there a better way to do it ?
>
> Thanks in advance, Thomas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org