I use TWebBrowser to insert data into a web form. My application is written in Delphi FMX and runs on Android. The element type text is not inserting the value string.
HTML:
<input
type="text"
name="txtCPF"
id="txtCPF"
size="18"
maxlength="14"
autofocus=""
title="Informe os onze dígitos do número do CPF."
onkeypress="javascript: return EntradaNumerico(event);"
onfocus="javascript: RemoveMask('txtCPF');"
onblur="javascript: FG_FormatarCPF('txtCPF');"
autocomplete="off"
value=""
>
I need to insert into element txtCPF the value type String '02403989987', but
if use this code:
var wbConsultaCPF: TWebBrowser; begin wbConsultaCPF.EvaluateJavaScript('document.getElementById("txtCPF").value = "012345";');...the browser shows just
012345
in white screen. In an iOS application, the code works correctly.
If I use:
wbConsultaCPF.EvaluateJavaScript('document.getElementById("txtCPF").value = 012345;');...the browser shows the correct text in the element value, but cuts off the first zero:
12345
wbConsultaCPF.URL := 'https://servicos.receita.fazenda.gov.br/servicos/cpf/consultasituacao/ConsultaPublica.asp';
I created a function in .EvaluateJavaScript() and it worked. Example:
wbConsultaCPF.EvaluateJavaScript('(function() { document.getElementById("txtCPF").value = "012345"; })()');