I've spent the better part of two days attempting to have fields with
validators enabled and disabled through javascript and having it work.

Here's the situation:

I have a form with several fields on it. They are always visible and
required. There is a checkbox that, when clicked, uses javascript to
show another textfield. I want this textfield to be required, using the
required validator. The problem is that I only want it to be validated
or even submitted if the user clicks the checkbox. By default, the field
is disabled. Even if javascript enables the field, it never gets
validated and is always null in my listener. If the field is enabled by
default and I use javascript to disable the field, it always gets
validated, even though it is disabled.

<box jwcid="@Checkbox" value="ognl:fieldChecked"
onclick="ognl:fieldCheckedJavascript"/>Show Field<br />
<div id="fieldDiv" style="display:none">
        <field jwcid="@TextField" id="ognl:fieldId"
value="ognl:optionalRequiredData" disabled="true"
validators="validators:required"/>
</div>

The fieldCheckedJavascript toggles the display value of the fieldDiv to
show/hide the field. It also toggles the disabled property of the
textfield so that it is disabled when hidden and enabled when in view.
The required validator never validates the field, regardless of the
state. If I remove the disabled by default, then the field is always
required, even if set to disabled with the javascript.

I could use some ideas, or let me know if this isn't possible in T4.

Thanks,
-Wes Bramhall

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to