Mailing List Archive

Form::Validate and Internet Explorer
Hello list,

I've another problem! With Embperl::Form::Validate I generate a
javascript and check if the e-mail address is valid. With firefox and
mozilla it works very well, but the internet explorer (6.0.2) always
say the e-mail address is not valid. Is the generated Javascript
incompatible?

Thanks in advance
greets
cit

Here some code, but I don't think this can be the problem.

## my template

use Embperl::Form::Validate;
my $epf=Embperl::Form::Validate->new([.[.
-key => 'email',
emptyok => 1,
-msg => 'no valid email
address', -type => 'EMail',
]]
);

<script type="text/javascript" language="JavaScript">
<!--
[+ do { local $escmode = 0; $epf->get_script_code } +]
//-->
</script>
<form action="user.tmpl" method="post" name="add_user" onSubmit="return
epform_validate_forms_0_()">

## the generated javascript
<script type="text/javascript" language="JavaScript">
<!--
function epform_validate_forms_0_()
{
var msgs = new Array ;
var fail = 0 ;
var i = 0 ;
var obj ;

do {

do {

do {
obj = document.forms[0]['email'] ; if (!(obj.value)) { break;}
obj = document.forms[0]['email'] ; if (!(((obj.value.search(/^[^
<>()@¡-ÿ]+@[^ <>()@¡-ÿ]+\.[a-zA-Z]{2,4}$/) >= 0) &&
(obj.value.search(/@(\.|.*(\.\.|@))|mailto:/i) < 0))))
{ msgs[i++]='keine gültige E-Mail Adresse'; break;} } while (0) ; if
(fail) break ; } while (0) ; if (fail) break ;
;
}
while (0) ;
if (i)
alert (msgs.join('\n')) ;

return !i ;
}
//-->
</script>

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Form::Validate and Internet Explorer [ In reply to ]
I'd personally advise against using 8-bit characters in javascript; my
experience is that such is not portable. Also, I trust that you are
still checking on the back end - it's relatively easy to disable
javascript.

To do this check without 8-bits, I believe the logic needs to be
reversed - what isn't legal. I much prefer to do the check the way
Embperl::Form::Validate does it, but I have the advantage of not having
to support non-ASCII email addresses.

Of course, you could always try saying IE isn't supported. ;>

Ed

On Mon, 3 Apr 2006, Florian 'cit' Adamsky wrote:

> Hello list,
>
> I've another problem! With Embperl::Form::Validate I generate a
> javascript and check if the e-mail address is valid. With firefox and
> mozilla it works very well, but the internet explorer (6.0.2) always
> say the e-mail address is not valid. Is the generated Javascript
> incompatible?
>
> Thanks in advance
> greets
> cit
>
> Here some code, but I don't think this can be the problem.
>
> ## my template
>
> use Embperl::Form::Validate;
> my $epf=Embperl::Form::Validate->new([.[.
> -key => 'email',
> emptyok => 1,
> -msg => 'no valid email
> address', -type => 'EMail',
> ]]
> );
>
> <script type="text/javascript" language="JavaScript">
> <!--
> [+ do { local $escmode = 0; $epf->get_script_code } +]
> //-->
> </script>
> <form action="user.tmpl" method="post" name="add_user" onSubmit="return
> epform_validate_forms_0_()">
>
> ## the generated javascript
> <script type="text/javascript" language="JavaScript">
> <!--
> function epform_validate_forms_0_()
> {
> var msgs = new Array ;
> var fail = 0 ;
> var i = 0 ;
> var obj ;
>
> do {
>
> do {
>
> do {
> obj = document.forms[0]['email'] ; if (!(obj.value)) { break;}
> obj = document.forms[0]['email'] ; if (!(((obj.value.search(/^[^
> <>()@¡-ÿ]+@[^ <>()@¡-ÿ]+\.[a-zA-Z]{2,4}$/) >= 0) &&
> (obj.value.search(/@(\.|.*(\.\.|@))|mailto:/i) < 0))))
> { msgs[i++]='keine gültige E-Mail Adresse'; break;} } while (0) ; if
> (fail) break ; } while (0) ; if (fail) break ;
> ;
> }
> while (0) ;
> if (i)
> alert (msgs.join('\n')) ;
>
> return !i ;
> }
> //-->
> </script>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Form::Validate and Internet Explorer [ In reply to ]
Hello,

On Mon, 3 Apr 2006 16:40:37 +0000 (GMT)
wrote Ed Grimm <edgrimm@dsblade00.wat.us.ray.com>:

> I'd personally advise against using 8-bit characters in javascript; my
> experience is that such is not portable. Also, I trust that you are
> still checking on the back end - it's relatively easy to disable
> javascript.

Yes, that's clear. I'm checking the import form fields on the back end.
But in this case it is a e-mail address. If the user disable javascript
and enter an invalid e-mail address, he will never get a mail from the
system.

> To do this check without 8-bits, I believe the logic needs to be
> reversed - what isn't legal. I much prefer to do the check the way
> Embperl::Form::Validate does it, but I have the advantage of not
> having to support non-ASCII email addresses.

I've check it without 8-bits, but without success. This is not so
important, but I thought that this is an mistake in the generated
javascript.

> Of course, you could always try saying IE isn't supported. ;>

This browser is a nightmare ... ;-)

greets
cit



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org