Gossamer Forum
Quote Reply
Form Regex
I'm currently using JScript to keep commas out of a form box thus:

Code:
function filterNum(str) {
re = /^\$|,/g;
return str.replace(re, "");
}
Of course, the ideal solution would be a form Regex but I have no clue about these.

Any suggestions on what to use for this.

Many thanks.

- Eraser

Quote Reply
Re: Form Regex In reply to
In add.cgi in the relevant place add.....

Code:
if ($IN->param('FIELD') =~ /,/g) {
print $IN->header();
print Links::SiteHTML::display('error', { error => Links::language('ADD_COMMA')});
return;
}
You will need to change the red bit to the correct field name and also define the error value - ADD_COMMA.

You may need to use....

Code:
if ($IN->param('FIELD') =~ /\,/) {
...but the first example seemed to work ok for me.





Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Form Regex In reply to
Hi,

I might wait for the looming upgrade before I start hacking the script though
as other changes I need are going into the script.

Thanks for the codes!

- Eraser.

Quote Reply
Re: Form Regex In reply to
You could probably make a quick plugin to hook into add.cgi before the form is submitted which checks for commas, that way the plugin can just be re-installed when you upgrade.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/