Input Filters in Drupal : DO NOT ALLOW SPECIFIC CHARACTERS

brollo - May 3, 2008 - 23:37

Hello all,

I am trying to figure out how to disallow users to enter specific characters (such as "@", "/", "&" or whatever) in input fields.

I am particularly interested in avoiding users in entering such characters when :

1) Entering Titles of CCK nodes
2) Entering taxonomy terms through free taggable vocabularies

Any ideas please?

_validate

pwolanin - May 4, 2008 - 01:55

Add your own, additional, validation function to the form via a custom module.

http://api.drupal.org/api/file/developer/topics/forms_api.html/5

overriding node validate or what

brollo - May 4, 2008 - 23:40

So are you suggesting to override the default node.module form validation function to check on nasty characters for title ?
taxonomy.module for free taggable terms?

Could you be more specific if needed please?

A quick dirty trick I did now, is just simply replace bad characters with "" blank string, but I get some "holes" in the DB..

additional validation

pwolanin - May 6, 2008 - 01:02

Don't override the normal validation - rather add an additional validation function via hook_form_alter in a custom module.

 
 

Drupal is a registered trademark of Dries Buytaert.