cforms II User Forum

Registration is currently disabled.


Lost password?
Advanced Search:

— Forum Scope —

— Match —

— Forum Options —

Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Reg Ex Validation not working
September 26, 2007
1:56 am

I am having issues when trying to use Regular Expressions.

Following your help file, I have setup a field as:

$fields['label'][19]  ='Reference #|xxx-xx-xxx|^[0-9]$';

However, I am still able to enter letters, should this not just accept numerics?

and if I add:

$fields['label'][19]  ='Reference #|xxx-xx-xxx|^[0-9]$|err: Reference only numbers';

I should receive a custom error message, but I do not.

Any ideas on where to diagnose my problem?

September 26, 2007
7:40 am
Munich, Germany
Forum Posts: 6400
Member Since:
March 6, 2005

$fields[’label’][19]  =’Reference #|xxx-xx-xxx|^[0-9]+$';

There should be a '+' after the [...]. 

Also, ensure to check "Is Required" to enable regexp validation!

The custom err part should then work, too. 

You also might want to see this for a slightly more flexibly way of dealing with large custom form arrays…(it's in German, but I'm sure you get the idea).

Forum Timezone: Europe/Berlin

Most Users Ever Online: 959

Currently Online:

Top Posters:

tracedef: 43

mores: 21

Gyrus: 20

frozenwaste: 18

asuffredini: 15

photoworks: 14

Member Stats:

Guest Posters: 3714

Members: 1463

Moderators: 3

Admins: 2

Forum Stats:

Groups: 1

Forums: 4

Topics: 5311

Posts: 18673

Newest Members: juredujmovic, dreamkeeper, rajattyagi, wrokaa, lukass

Moderators: Paul (421), cnymike (8), sonika (95)

Administrators: Oliver (6400), Nicky (3)