Preventing special characters in tridion component field and changes in schema

126 Views Asked by At

In component, I should not allow any special characters to be entered. When I try to enter a comma, it should suggest "no special characters allowed". Please suggest where do I make the necessary changes. I tried making some changes in schema(source) like adding but not working.

<xsd:element name="FileName">
 <xsd:simpleType>
  <xsd:restriction base="xsd:string">
   <xsd:pattern value="[a-zA-Z0-9_.' !@#$%^*()_+={}|/:;,>?/`~ ]"/>
  </xsd:restriction>
 </xsd:simpleType>
</xsd:element>
1

There are 1 best solutions below

0
On

What you're asking for is a custom validation that may not be best accommodated via the Schema (XSD). You may be able to do it there via a feature called facets. Check the sdllive docs for examples. You can make it give you validation error messages, but you cannot customize the messages themselves, and they are ugly and scary looking for the average content editor.

The other approaches are:

1) develop a custom event via the Event System. This is the easiest option IMO. Simply throw an exception with a custom message on a Compenent Save event in the Init phase.

2) develop a custom GUI extension to do the validation. This IMO is more work than the above, but is achievable.