Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Aiheen aloitti: escaperadius - helmikuu 22, 2009, 07:00:08 IP

Otsikko: Input Mask with Regex not filtering
Kirjoitti: escaperadius - helmikuu 22, 2009, 07:00:08 IP
I have created a custom profile field where I want a user to enter a vaild domain name (like www.mysite.com) at registration.

In the Edit Profile Field->Advanced Settings: form I have selected Regex (Advanced) and placed
^(http|https)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$

The custom field appears on the registration page however it doesn't force the regex validation rule. It does reject registration if the domain name field is empty.

What needs to be done to correct this and enforce the regex validation?
Thanks,
Chris
Otsikko: Re: Input Mask with Regex not filtering
Kirjoitti: karlbenson - helmikuu 22, 2009, 07:54:29 IP
It doesn't look like a good regex to me.

Besides the fact you should start and end with the same character. (has to be not included in your regex or has to be escaped everytime in regex eg

~^[a-z]+$~ (since tilda is not allowed in url unencoded)