Regular Expression for validating that Form Inputs don't contain special characters
Hi,
I spent weeks trying to find how to do this - so I thought it would be a good idea to tell other people.
Here's a form input with regular expression, that validates that there are no
{{, }} or |
characters in the field:
(Ref https://bugzilla.wikimedia.org/show_bug.cgi?id=30042 and http://wikimedia.7.n6.nabble.com/Semantic-Forms-Need-better-input-checking-td555083.html)
{{{field|Description
| input type=regexp
|base type=regexp
|or char=;
|regexp=/(?:^\{\{VALIDATIONOFF\}\};^(?:(?!\{\{;\}\}).)*$)/
|message=Dont use }} or {{ without making sure that you always have a matched pair of brackets. To bypass this warning please put { {VALIDATIONOFF} }; at the very beginning of your input (without the spaces).
|base prefix=filter2
|filter2.regexp=/\!/
|filter2.inverse
|filter2.message=Don't use a pipe {{!}} in the input. Use { {!} } instead (without the spaces and not inside <pre>)
|filter2.base type=textarea
|rows=10|cols=100|autogrow
}}}