Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Custom link fields

Quote Reply
Custom link fields
I am adding a few custom link fields to the database.

One field is for telepnone number and another is for zipcode. Is there a way to set the field for telephone number to display with three boxes seperated by hyphens? I am guessing that this may be done in Regex? Also I have set the zipcode to INT how would I limit it to 7?

Last question - I want a description field to be more than 255 so I am setting it as TEXT. Is there a way to limit the amount of text to say 500?

TIA
Quote Reply
Re: [jgkiefer] Custom link fields In reply to
I'm not the best with regex...but what about;

^[\d]{,7}

thats for the 7 digit ZIP code

^[\d]{,3}\-[\d]{,3}-[\d]{,3}$

Thats for the phone number, seperated by -


Like I said, they may (probably) won't work, cos its early in the morning, and I'm off to the dentist, so my brain isn't working great at the moment Wink

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Custom link fields In reply to
I'll give it a try. Is there a way to limit the number of characters in a text field?

I know it's early, dentist? Yuck Tongue
Quote Reply
Re: [jgkiefer] Custom link fields In reply to
if ($Field !~ /^[your words and charachters allowed here]{0,200}/i) { erorr here if match isnt made }

The {0,200} can be changed. First number is the min, and last is the maximum charachers.

Hope that helps Smile

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Custom link fields In reply to
Quote:
if ($Field !~ /^[your words and charachters allowed here]{0,200}/i)

You won't have much luck if you use words :)
Quote Reply
Re: [Paul] Custom link fields In reply to
Thanks I'll give it a try.
Quote Reply
Re: [Paul] Custom link fields In reply to
In Reply To:
Quote:
if ($Field !~ /^[your words and charachters allowed here]{0,200}/i)

You won't have much luck if you use words :)
Can I just leave out the [your words and charachters allowed here] string to just set the lenght? I'm guessing yes?
Quote Reply
Re: [jgkiefer] Custom link fields In reply to
No :)

You can do this though:

Code:
unless ($field =~ /^.{0,200}$/) {

...but better would be:

Code:
unless (length($field) and length($field) < 201) {

Last edited by:

Paul: Dec 10, 2002, 9:27 AM
Quote Reply
Re: [Paul] Custom link fields In reply to
In Reply To:

Code:
unless (length($field) and length($field) < 201) {


I would put that in the [your words and charachters allowed here]. Or just use that string in the Regex. How about the error message? Unsure

Thanks ahead of time for all the help. I really do appreciate it.
Quote Reply
Re: [Andy] Custom link fields In reply to
In Reply To:
I'm not the best with regex...but what about;

^[\d]{,3}\-[\d]{,3}-[\d]{,3}$

Thats for the phone number, seperated by -


Shouldn't that be?

^[\d]{,3}\-[\d]{,3}-[\d]{,4}$

3 numbers-3numbers-4numbers
Quote Reply
Re: [Paul] Custom link fields In reply to
In Reply To:
Quote:
if ($Field !~ /^[your words and charachters allowed here]{0,200}/i)

You won't have much luck if you use words :)


I'm a bit confused with this one. Is this a regex or an if statement? Could you maybe give me the correct code and where to put it?

Thanks Paul, you have helped me so much and I really do appriciate it. Blush
Quote Reply
Re: [jgkiefer] Custom link fields In reply to
Quote:
Shouldn't that be?

^[\d]{,3}\-[\d]{,3}-[\d]{,4}$


How about this one:

Code:
^/([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d\d?|2[0-4]\d|25[0-5])$



That should give you a pretty accurate match :)