Malin
Malin

Reputation: 697

XPages: disabled property breaks required computation for xp:inputText

On my application I have an xp:inputText control with the disabled property set to true and the required property computed as followed:

<xp:inputText 
    id="txtSecurityLevel"
    styleClass="form-control-static"
    value="#{employeeBean.employee.securityLvl}" 
    disabled="true" 
    >
    <xp:this.validators>
        <xp:validateRequired
            message="Unsufficient level of security">
        </xp:validateRequired>
    </xp:this.validators>
    <xp:this.required><![CDATA[#{javascript:return submittedBy("btnProceed")}]]></xp:this.required>
</xp:inputText>

The value of the field is pre-populated and I do not want users to alter the value.

When I use the same approach for other inputText controls but with the disabled property set to false the validation is initiated for these fields.

Is there another approach I should use?

Upvotes: 0

Views: 54

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

To make the field non-editable, use the readonly property.

Internet Explorer used to allow the disabled and readonly property interchangeably. But with IE10 they changed the behaviour so disabled worked as in other browsers, i.e. the value is not passed from the browser to the server. Because it's not passed back from the browser, your validation fails. disabled is for an input that should be unusable for the browser, see https://www.w3schools.com/Tags/att_input_disabled.asp. What you want is for it to be readonly for the user.

Upvotes: 1

Related Questions