0
votes

I have a requirement to limit the maxlength of an integer field to 10 digits. But it seems like if we bind the type to integer, the maxlength is not working for input field.

<xforms:bind id="int-field" nodeset="instance('prepop')/type/int-field" type="xs:integer"/>

<xforms:input bind="int-field" xxforms:maxlength="10">
<xforms:alert>Required</xforms:alert>
</xforms:input>

And if I remove that type="xs:integer" from the bind, the maxlength works fine.

Please suggest me an alternative?

1
See my response below: if it isn't working in your case because you have something slightly different than the full example I posted, I'll let you update your question—posting a full example is always better—and also don't forget to add a comment to my response so I get a notification from Basecamp. - avernet

1 Answers

1
votes

This seems to be working fine with the latest nightly build, and the following full example:

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
    <xhtml:head>
        <xhtml:title>Input bound to integer node with maxlength attribute</xhtml:title>
        <xforms:model>
            <xforms:instance>
                <instance>123</instance>
            </xforms:instance>
            <xforms:bind nodeset="." type="xs:integer"/>
        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <xforms:input ref="." xxforms:maxlength="10">
            <xforms:alert>Required</xforms:alert>
        </xforms:input>
    </xhtml:body>
</xhtml:html>