W3C home > Mailing lists > Public > www-forms@w3.org > May 2004

Xforms Validation

From: Pierre Busnel <pierre2803@lycos.com>
Date: Thu, 27 May 2004 13:20:30 +0100
To: www-forms@w3.org
Message-ID: <COGNPEHCOBNNIKAA@mailcity.com>


  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 ?


  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">

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

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

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:36:13 UTC