RE: Data Validation

 Robert,

Looks like you need to modify your pattern statement in your schema to
make this work:

<xsd:simpleType name="zipCodeType">
	<xsd:restriction base="xsd:string">
		<xsd:minLength value="5"/>
		<xsd:maxLength value="10"/>
		<xsd:pattern
value="[0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]"/>
	</xsd:restriction>
</xsd:simpleType>


Thank you,

Christopher M Goodrich A+
Corporate Computing Help Desk
Sandia National Laboratories
Science Applications International Corporation
cmgoodr@sandia.gov
(505) 284-4797 

-----Original Message-----
From: www-forms-request@w3.org [mailto:www-forms-request@w3.org] On
Behalf Of David Landwehr
Sent: Wednesday, February 09, 2005 9:45 AM
To: 'XForms mailing list'
Subject: RE: Data Validation


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:54:30 UTC