W3C home > Mailing lists > Public > www-forms@w3.org > February 2005

Data Validation

From: Robert Bateman <bobbateman@sequoiallc.com>
Date: Wed, 09 Feb 2005 11:15:00 -0500
To: XForms mailing list <www-forms@w3.org>
Message-Id: <1107965700.3599.42.camel@development.sequoiallc.com>

Question for the *experts* on the list:

What is the best way to insure validity of data within an XForms forms? 
Let me explain my question...

I have a schema that contains a definition for a US postal code.  The
field definition in the schema looks like:

<xsd:simpleType name="zipCodeType">
	<xsd:restriction base="xsd:string">
		<xsd:minLength value="5"/>
		<xsd:maxLength value="10"/>
		<xsd:pattern value="\d{5}(-\d{4})?"/>

Pretty straight forward stuff.  I have instance data in a form that I
put my zip code into.  The instance field is <ZipCode
xsi:type="zipCodeType"/>.  All is well so far.

On my form, I bind an input field to my instance data.  When the form
loads, there is nothing in ZipCode, so my CSS for invalid fires and I
get a red box around ZipCode (as expected...)  When I put data into
ZipCode and leave the field, ZipCode is no longer "invalid" as it now
contains data.  My player removes the red box around ZipCode because of
my CSS valid entry.

So...  Here's my dilemma:  If I enter 12345 as my data, the value in
ZipCode is "correct" according to the schema.  If, however, I enter
1234A - the data is incorrect according to the schema.  

What I want to do is to reevaluate my data for correctness according to
the schema.  But I'm uncertain "where" the best place to do that is.  I
know the data is supposed to be validated during the submit process. 
But to me, that is a bit late in the game.  

Does anyone have a recommendation for a better way and time for
reevaluation data validity?  Personally, I would prefer to evaluate the
data entered as the user leaves fields - this way, invalid data is
caught much quicker.

Received on Wednesday, 9 February 2005 16:14:28 UTC

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