none
Validate a certain number of input tags RRS feed

  • Question

  • My users will add text to be translated.
    Inside the text we would like to allow a certain number of tags.
    Most of them will be simple formatting but some can be extended to cover reserved words etc.

    Now we would like to validate user input to ensure correct entries.

    The assumption is to use HTML like formatting tags like: <b>, <br/>, <ul>, <li>, etc.
    Even definitions could probably be covered by HTML if using something like: <code>, <cite>, <dfn>
    This means it is fully possible to limit tags to valid HTML if that helps.

    My initial guess is that Regex is faster since we will only allow a very limited number of tags.
    But that validation soon becomes very complex, especially if we allow nested tags which is very much preferred and even necessary for <ul> lists.

    Is there maybe a XHTML validator that might be possible to use?

    I saw that TinyMCE has a similar input validation, but I am not able to detect how they actually process and apply it.
    I still would prefer C# based solution over javascript.

    Wednesday, April 6, 2011 1:25 PM

Answers