Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

How to validate a field using validation patterns

Avatar

Level 2

Hello

I'm having a problem trying to validate a numeric field in LiveCycle - can't quite figure out how the pattern works...

The field I’m trying to validate is a numeric field from a XSD file. The wanted validation pattern is the user entered value must range between 0-36.

Do any of you know how to do?

Best regards,

Mathias

1 Reply

Avatar

Former Community Member

Mathias,

If you are referring to extending a schema restriction in Designer, read on.

Consider the following schema which has a restriction on 'age' of '0-36'

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="customer">
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name="firstName" type="xsd:string"/>
    <xsd:element name="lastName" type="xsd:string"/>
    <xsd:element name="age">
     <xsd:simpleType>
      <xsd:restriction base="xsd:integer">
      <xsd:minInclusive value="0"/>
      <xsd:maxInclusive value="36"/>
      </xsd:restriction>
     </xsd:simpleType>
    </xsd:element>
   </xsd:sequence>
  </xsd:complexType>
</xsd:element>

</xsd:schema>

Consider starting with a new, blank form and creating the data connection to the schema, above. Once you have created the connection, right-click on the connection name and click 'Generate Fields'.

a.png

The fields are added to the form and the restriction on 'age' is automatically turned into validation script on the calculate event of 'age'.

b.png

Steve