[Pas2js] is it a bug fro pas2js?

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Aug 17 17:56:16 CEST 2019


On Fri, 16 Aug 2019 11:27:57 -0400
Pedro Pablo Oviedo Vera <verakuba13 at gmail.com> wrote:

> Hello, I have a problem:
> I writing an event handler for invalid input from a html form element
> in order to get a validation on real time:
> 
> FFormulario1            :=
> TJSHTMLFormElement(document.getElementById('informacion1'));
> FFormulario1.oninvalid  :=@Form2Validacion;
> 
> before I defined
> 
> function Form2Validacion(aEvent: TJSEventhandler): Boolean;
> begin
>   window.alert('Hay un campo con valores incorrectos!!!');
> end;
> 
> knowing in web.pas say:
>  TJSHTMLFormElement = class external name 'HTMLFormElement'
> (TJSHTMLElement)
> 
>  TJSHTMLElement = class external name 'HTMLELement' (TJSElement)
>  public
>  oninvalid : TJSEventhandler;

TJSEventhandler is defined as
  TJSEventHandler = reference to function(Event: TEventListenerEvent): boolean;

>  ...
> 
> but Lazarus in compile time shut me:
> project1.lpr(262,28) Error: Incompatible type arg no. 1: Got
> "TEventListenerEvent", expected "TJSEventHandler"

Correct.

 
> if I change to:
> function Form2Validacion(aEvent: TEventListenerEvent): Boolean;
> 
> and then Lazarus compiles Ok!!!

Yes.

 
> but my browser claim to me with all justice:
> TypeError: $mod.FFormulario1 is null!!!!

That probably means 
document.getElementById('informacion1')
returned nil.

Check if FFormulario1 is nil and if "informacion1" is correct. Case
sensitive.
 
Mattias


More information about the Pas2js mailing list