Search code examples
javascriptadobelivecyclelivecycle-designer

Adobe LiveCycle. Conditional character limit based on option selected from radio button


I have a radio button that the user has to choose either A or B. Depending on the choice I would like it to affect the character limits for the rest of the form.

Sample code from the internet that controls the character limit from the form (Source: Assure Dynamics).

if (this.rawValue.length > 25)
{
var vInput = TextField3.rawValue.toString();
this.rawValue = vInput.substring(0,25);
}

I would like to modify the script such that the value 25 is changed to 50 if B is selected.


Solution

  • Maybe have a variable "limit" that is updated on the radio button onchange event?

    var limit = 25;
    
    function onRadioChange () {
        if(getElementById('radio50').checked) {
            limit = 50;
        } else {
            limit = 25;
        }
    }
    
    if (this.rawValue.length > limit) {
        var vInput = TextField3.rawValue.toString();
        this.rawValue = vInput.substring(0,limit);
    }