Xforms Validation

  Hi,

  I've been trying in vain to add constraints to a xforms. What I am trying to do is to make sure the user will enter an integer in a certain field. I found easy to test the length of a field or others things using Xpath functions, but I dont see how I can test the type or how I can use regular expressions. 
  In the code below, the user can enter a 2 characters string, even if the type is an integer. How can I prevent the user from entering anything else than numbers ?

  Regards 

  Pierre Busnel 

PS: By the way, I think Xforms is the "next big thing". Or I'll be damned to try to understand how it works for nothing !!

--- controls.xforms ---   

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/1999/XMLSchema">

<head>
<link rel="stylesheet" type="text/css" href="xforms.css" />
<xforms:model xforms:id="model_0">
<xforms:instance xforms:id="instance_0">
<liste>
	<champ1/>
</liste>
 </xforms:instance>
 
 <xforms:bind xforms:id="bind_1" nodeset="instance('instance_0')/champ1" type="xs:integer" constraint="string-length()=2" required="true()"/>
 
 <xforms:submission action="http://192.168.9.12:8080/xform/app" method="post" id="submit" />
 </xforms:model>
 </head>
 <body>

  <xforms:input xforms:bind="bind_1">
      <xforms:label>Champ 1</xforms:label>
  </xforms:input>
 
  <xforms:trigger>
    <xforms:label>Submit</xforms:label>
    <xforms:action ev:event="DOMActivate">
      <xforms:message ev:event="xforms-invalid" level="modal"> invalid field </xforms:message>
      <xforms:send submission="submit"/>
    </xforms:action>  
 </xforms:trigger>


 </body>
 </html>

Received on Thursday, 27 May 2004 08:21:08 UTC