-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pushkar,

[EMAIL PROTECTED] wrote:
> Yes, I was expecting client-side validation to work for URLs. And ya, other
> validations like "required", "email", "maxlength"..etc are working fine on
> this form.

There was a bug in URLValidator that made it fail for even simple URLs
like http://www.google.com, so I had to dump it and use a regular
expression mask instead. (The URLValidator has since been patched and
works fine).

Since javascript can easily do regular expressions, you can use this
regular expression to check your URLs. I went through the HTTP URL
specification and attempted to include everything I could see for the
regexp. The only problem is that it allows any protocol, even fictional
ones (like joke://abc.com/).

(Yes, this is a very long regular expression. Hopefully, it will come
out on one line).

^[a-zA-Z][a-zA-Z0-9\+\-\.]*:(//(([a-zA-Z0-9\-_\.!~\*'\(\)%;:&\+\$,]*@)?(([a-zA-Z0-9][a-zA-Z0-9-]*\.)*[a-zA-Z][a-zA-Z0-9]*|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(:[0-9]+)?)(/[a-zA-Z0-9\-_\.!~\*'\(\)%:@&=\+\$,]*(;[a-zA-Z0-9\-_\.!~\*'\(\)%:@&=\+\$,]*)*(/[a-zA-Z0-9\-_\.!~\*'\(\)%:@&=\+\$,]*(;[a-zA-Z0-9\-_\.!~\*'\(\)%:@&=\+\$,]*)*)*)?)(\?[;/\?:@&=\+\$,a-zA-Z0-9\-_\.!~\*'\(\)%]+)?$

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFwMzF9CaO5/Lv0PARAsdjAJ0W+zKn2BMmqCzfCNgXfIKcDpld2wCfZzUu
79SZk6zCam4Na9xhGuA6V0E=
=w1MJ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to