validation in xsd for string and date

Posted by Sugi under C# on 7/29/2013 | Points: 10 | Views : 704 | Status : [Member] | Replies : 2
need example for validation in xsd 1.to allow only 45 characters 2. allow dateformat in mm/dd/yyyy .




Responses

Posted by: Ssj_Kumar on: 7/30/2013 [Member] Starter | Points: 25

Up
0
Down
For Date

<xsd:element name="DOB" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0,1]{1}[0-9]{1}/[0-3]{1}[0-9]{1}/[0-9]{4}"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

For 45 Charater
<xsd:element name="Address" minOccurs="0">
<xsd:simpleType>
<xsd:restriction base="xs:string">
<xsd:maxLength value="45"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>



Regards,
Jayakumar Selvakani

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 7/30/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
<xs:simpleType name="DateFormatValidation">
<xs:restriction base="xs:string">
<xs:maxLength value="10"/> --------------------------------------------------> Like this you can restrict max length
<xs:pattern value="((0[1-9]|1[012])[-](0[1-9]|1[031])[-](19|20)\d\d)?"/> ----------------------> this is for MM-DD-YYYY
</xs:restriction>
</xs:simpleType>

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Sugi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response