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

RE: Data Validation

From: David Landwehr <dlandwehr@novell.com>
Date: Wed, 9 Feb 2005 17:44:41 +0100
To: "'XForms mailing list'" <www-forms@w3.org>
Message-Id: <20050209164441.DF23447FEB7@pfepa.post.tele.dk>

Hi Robert,

I'm a little confused. The data should be validated against the schema as
you move out of the input field. So in your example with 1234A the input
field should show up as being invalid right after you move out of the field.

Best regards,
David

-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On Behalf
Of Robert Bateman
Sent: 9. februar 2005 17:15
To: XForms mailing list
Subject: Data Validation


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})?"/>
	</xsd:restriction>
</xsd:simpleType>

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.

Bob
Received on Wednesday, 9 February 2005 16:44:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:21:59 GMT