Gossamer Forum
Home : Products : DBMan : Customization :

validate input ?

Quote Reply
validate input ?
HelloSmile

How can i validate the input? That's the question!
I have a record field where the user fills in his/her phonenumber. The user can fill in whatever he/she likes, but the default is starting with "^06-" and only numbers can be filled in..
What i like to check is if the phonenumber is the right format. The phonenumbers have to start with 06-1, 06-2, 06-57, 06-967, 06-53.All other numbers are not allowed, so they should get a message telling that the number is not ok.
I don't want to have a select box on my inputscreen, so the input of the phonenumbers should be checked in the sub validate_record ,but i don't know how.
Does someone know how to fix this?

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: validate input ? In reply to
Hobo:

Check the FAQ referenced below under "Syntax". You will find information for setting up phone number fields. You may have to modify the examples provided to suit your needs, but you may be able to figure it out quickly using the examples.

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: validate input ? In reply to
hello again.

Thanks for your reply, but i already checked that link and i can't see a possible solution for my problem (Newbie, sorrry). I have to check for some numbers only, but i still don't know how to fix this.Blush

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: validate input ? In reply to
Search this forum and the Links SQL forum for phone number and you will find a few Threads where regular expressions for phone numbers have been discussed. You can use these regular expressions in the valid expression column in the %db_def hash in the default.cfg rather than hacking the sub validate_record routine in the db.cgi file.

Regards,

Eliot

Quote Reply
Re: validate input ? In reply to
thanks eliot i give it a try

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: validate input ? In reply to
hello,
I could not find what i am looking for.
This is what i already have:

in default.cfg at database definition %db_def

'06nummer' => [6, 'nummer', 11, 11, 1, '06-', '^06-\d{8}$' }

This is working OK. But i dont know how to rewrite the lastpart.
The phonenumber ('06nummer') always has to start with 06-.
Also when someone fills in a number it has to start with 06-1#######, 06-2#######, 06-57######, 06-967#####, 06-53######.( #=other numbers ) All other numbers are not allowed (like 06-4#######)
mmh this should be easy, isn't it?

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: validate input ? In reply to
(Thanks for your nice message to me. Smile)

You can set up quite a long regular expression:

'^06-1\d{7}$|^06-2\d{7}$|^06-57\d{6}$|^06-967\d{5}$|^06-53\d{6}$'

The | means "or".


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: validate input ? In reply to
hello JPDeniSmile

I'm glad you feel better.
Thanks for your reply it's working nice!

greetings,
[removed by request]
The Netherlands (Europe)