Liu, Aaron | 3 Jun 07:41

js_invalid_hidden not defined


	I got Warning: No message string found for 'js_invalid_hidden'
in my error_log. When I look at Messages.pm there is no default for it,
and even if I define one during new() it didn't get used. I think this
comes from the line:

	my $et = 'js_invalid_' . ($type eq 'text' ? 'input' : $type);

from sub jsmessage. Maybe it should use js_invalid_default instead?

Nate Wiger | 3 Jun 17:40
Picon
Gravatar

Re: js_invalid_hidden not defined

Liu, Aaron <aaron.liu <at> asianetcom.com> wrote:
> 
>        I got Warning: No message string found for 'js_invalid_hidden'
> in my error_log. When I look at Messages.pm there is no default for it,
> and even if I define one during new() it didn't get used. I think this
> comes from the line:
> 
>        my $et = 'js_invalid_' . ($type eq 'text' ? 'input' : $type);
> 
> from sub jsmessage. Maybe it should use js_invalid_default instead?

I'm confused - this would only be triggered if you're validating a
hidden field and then it fails validation somehow. What are you doing?

-Nate

Liu, Aaron | 6 Jun 03:29

RE: js_invalid_hidden not defined


	I got a hidden field that should be propagated in the form
between submission and I wanted to make sure it is there. So I have put
it in the required field with validate check as 'VALUE'. The error
occurs during form rendering only. When I submited the form eventually
it passed without perl/javascript error and passed validate function.

> -----Original Message-----
> From: Nate Wiger [mailto:nwiger <at> gmail.com] 
> Sent: Friday, June 03, 2005 23:40
> To: Liu, Aaron
> Cc: fbusers <at> formbuilder.org
> Subject: Re: js_invalid_hidden not defined
> 
> Liu, Aaron <aaron.liu <at> asianetcom.com> wrote:
> > 
> >        I got Warning: No message string found for 
> 'js_invalid_hidden'
> > in my error_log. When I look at Messages.pm there is no 
> default for it,
> > and even if I define one during new() it didn't get used. I 
> think this
> > comes from the line:
> > 
> >        my $et = 'js_invalid_' . ($type eq 'text' ? 'input' : $type);
> > 
> > from sub jsmessage. Maybe it should use js_invalid_default instead?
> 
> I'm confused - this would only be triggered if you're validating a
> hidden field and then it fails validation somehow. What are you doing?
(Continue reading)

Liu, Aaron | 7 Jun 04:01

RE: js_invalid_hidden not defined

Hi again,

	Upon my attempt in making a barebone example I realized my error
report was not exactly correct: the value js_invalid_hidden in messages
is indeed effective (but it is not used in any case and no default is
defined in Messages.pm). I was using 3.0201, but upgrading to 3.0202
didn't fix the problem. Anyway, here is the snippet (pass ?id=1 on the
url to trigger the warning in error log):

-------------------------------------------------
#!/usr/local/bin/perl

use strict;
use CGI;
use CGI::FormBuilder;

my $query=CGI->new;

my $id=$query->param('id');

my @fields=qw/role/;
my $form=CGI::FormBuilder->new(
  method=>'POST',
  name=>'test',
  fields => \@fields,
  reset=>0,
  validate=>{
    id=>'VALUE',
    role=>'VALUE',
  },
(Continue reading)

Steve Knoblock | 16 Jun 17:49

Re: **JUNK** validate entry a number within given range

On Thu, 16 Jun 2005 12:23:02 +0200, you wrote:

>dear list members
>
>The validation of values seems to work perfectly well, however, I wonder 
>whether
>it is possible to require a field-entry to be a number AND to fall 
>within a given
>range, e.g. between 0 and 10.  I know how to get a number, I don't know 
>how to
>check for the range.
>
>Any example will be greatly appreciated!

I've never tried it, but the FB docs suggest you can use a Perl
comparison for validation.

validate => {
rating => {
	perl       => '< 10'
                              },
                 },

I'm unsure if you can say

< 10 && $form->field("rating") > 0

to get the range.

If all else fails, you can write validation function
(Continue reading)

Jonas Smedegaard | 16 Jun 19:19
Picon
Favicon
Gravatar

Re: validate entry a number within given range


On 16-06-2005 12:23, Chris van Uffelen wrote:

> The validation of values seems to work perfectly well, however, I wonder
> whether
> it is possible to require a field-entry to be a number AND to fall
> within a given
> range, e.g. between 0 and 10.  I know how to get a number, I don't know
> how to
> check for the range.

If your range can be expressed as a limited number of digits instead,
you should need only a regexp like this (which should work for both
JavaScript and Perl validation):

validate => {
    number_between_1000_and_9999 =>
        '^[1-9][0-9]{3}$',
    number_between_10_and_9999 =>
        '^[1-9][0-9]{1,3}$',
    number_between_0_and_10000 =>
        '^(0|[1-9][0-9]{0,3}|10000)$',
    number_between_5_and_3000 =>
        '^(5-9]|[1-9][0-9]{0,2}|[1-2][0-9]{3}|3000)$',
},

 - Jonas

--
* Jonas Smedegaard - idealist og Internet-arkitekt
(Continue reading)

Brad Oaks | 16 Jun 21:22
Picon
Favicon

Re: validate entry a number within given range

Chris van Uffelen wrote:

> The validation of values seems to work perfectly well, however, I 
> wonder whether
> it is possible to require a field-entry to be a number AND to fall 
> within a given
> range, e.g. between 0 and 10.  I know how to get a number, I don't 
> know how to
> check for the range.

Hello Chris,

Below is the quick example I worked up.  There is probably a more slick 
way of putting the requirements into the validate statement, but I've 
done it with additional JavaScript using the 'jsfunc' parameter. 

Good luck, --bradoaks

use CGI::FormBuilder;

@fields = qw(age email mailing_list);
my $jsfunc = <<'EOJS';   # note single quote (see Hint)
    if (form.elements['age'].value >= 10) {
        alertstr += "Mr. T says, \"Age must be ten or under. Fool!\"\n";
        invalid++;
    }
EOJS

$form = CGI::FormBuilder->new(
             method => 'POST',
(Continue reading)

Jonas Smedegaard | 16 Jun 21:59
Picon
Favicon
Gravatar

Re: validate entry a number within given range


On 16-06-2005 21:22, Brad Oaks wrote:
> Chris van Uffelen wrote:
> 
>> The validation of values seems to work perfectly well, however, I
>> wonder whether
>> it is possible to require a field-entry to be a number AND to fall
>> within a given
>> range, e.g. between 0 and 10.  I know how to get a number, I don't
>> know how to
>> check for the range.
> 
> 
> Hello Chris,
> 
> Below is the quick example I worked up.  There is probably a more slick
> way of putting the requirements into the validate statement, but I've
> done it with additional JavaScript using the 'jsfunc' parameter.
> Good luck, --bradoaks
> 
> use CGI::FormBuilder;
> 
> @fields = qw(age email mailing_list);
> my $jsfunc = <<'EOJS';   # note single quote (see Hint)
>    if (form.elements['age'].value >= 10) {
>        alertstr += "Mr. T says, \"Age must be ten or under. Fool!\"\n";
>        invalid++;
>    }
> EOJS
> 
(Continue reading)

Alex Marcu | 17 Jun 14:23
Picon

new browser window

Hello,

I am new to FormBuilder and I am trying to get my form to open (on submit) a new
window and pass it the fields filled in by the form as CGI parameters.
I'm not very good in JavaScript, my (pretty naive) attempt was to try a
window.open(self.location) in the jsfunc which didn't pass anyting, probably
because doing this in the CGI::FormBuilder->new() is a bit early on ;-). Any
suggestions on how to do it right?

Thanks,
Alex Marcu

Nate Wiger | 20 Jun 07:05
Picon
Gravatar

Re: new browser window

> I am new to FormBuilder and I am trying to get my form to open
> (on submit) a new window and pass it the fields filled in by the
> form as CGI parameters.

First off, this is no longer a good idea, since popup blockers/etc
will kill your app. I started typing some code in, and it's easy to
do, but I realized it's just really not a good idea.

BUT, if you really want, here's a bare skeleton:

  if ($form->submitted && $form->validate) {
     # do misc stuff here

     # in 3.02
     my $qs = $form->query_string;
     print <<EOH;
<body onload="window.open('...?$qs')">
EOH
     exit;
}
print $form->render;    # unsubmitted form

Again, this is not really a good idea...

-Nate


Gmane