Reputation: 17373
I would like users to type in telephone number as below:
tel:+6411113100
i.e. the telphone number must start with tel:+
Could someone please show me how to apply the xsd validation to validate the above please?
Thank you.
Upvotes: 1
Views: 765
Reputation: 52858
I agree with Michael Kay's answer above concerning sensible design. However, if you really want to restrict the value, here's an example of how you could do it:
<xsd:simpleType name="telephoneNumber">
<xsd:restriction base="xsd:string">
<xsd:pattern value="tel:\+\d*"/>
</xsd:restriction>
</xsd:simpleType>
Upvotes: 3
Reputation: 163332
I would like users to type in telephone number as below: tel:+6411113100
I have to question whether this is a sensible design. For example, phone numbers are often presented with embedded spaces, and I can't see any good reason for preventing users entering the spaces if they wish. To put it another way, I would like to know what the users would like, not what you would like.
Upvotes: 3
Reputation: 7197
You need to define a "simple type" for the string. Restrict the type using 'string' as base (to capture also the tel:+ prefix) and use a pattern
element to restrict to 'tel:+' followed by digits.
Upvotes: 1