Hi! I’m a new Drupal user. I have a question about customizing data fields that the user enters. When the user registers and enters a value like postal code or ID number, how do I validate it to ensure that the format is (Letter – Number – Letter – Number – Letter – Number) for the postal code and that the ID number is within a certain range of numbers?

Is there a module that will help me do this? Any help would be great!

Thanks!
Jeff

Comments

ximo’s picture

Nodeprofile will do this I believe. See http://dev.shellmultimedia.com/node/46 for a good comparison of the alternatives to the core Profile module. I haven't tried the whole shabang of Nodeprofile, I just stuck with usernode + CCK as that was enough in my case (i.e. I didn't need to include the fields in the signup/account form).

jeffmasigan’s picture

ximo,
thanks for the reply, but nodeprofile doesn't allow for checking/validation of user entered data. any other suggestions?

thanks,
jeff

ximo’s picture

You could always make your own little custom module. It's really not that hard, but it does require some PHP skills. The API will help you along the way, and there are plenty of examples to look at (thanks to open source).

What you need to do, is basically use hook_form_alter() to alter the registration form (user_register). Then add the form element property #validate to fields you want to validate, specifying a validation function to be used.

The API has more information:
http://api.drupal.org/api/5/function/hook_form_alter
http://api.drupal.org/api/5/file/developer/topics/forms_api_reference.ht...

Or, you could send me a message and we could agree on a price for me to make a custom module for you. There might be a module out there that already does this, but I'm not aware of any..

jeffmasigan’s picture

ximo,
thanks for the help. i figured out how to validate. i used the cck combined with some other modules to validate the data entry by the user.

jeff

ximo’s picture

Hm, which modules did you use to validate? Might be useful for me as well, instead of having to write my own validation functions :)

Leeteq’s picture

Do you mind sharing with us which modules you use for the validation, and perhaps a brief explanation on how you fitted it together? Any custom PHP code anywhere? Thanks.

.
--
( Evaluating the long-term route for Drupal 7.x via BackdropCMS at https://www.CMX.zone )