Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

mascara e javascript

Participant ,
Mar 21, 2023 Mar 21, 2023

Boa noite,

 

Gostaria de colocar uma mascara em um campo e um codigo javascript para quando o campo estiver totalmente preenchido mude automaticamente para o proximo.

 

mascara para o campo deverá ser: "999 999 999"

 

Já tentei o codigo abaixo, mais não funciona, o que fiz de errado?

:

//formata com a mascara

var v = event.value;
if(v.length == 11)
v = util.printx("999 999 999", v);

else{
app.alert("Digite o formato correcto");
v = "";}
event.value = v;

 

//Mudar de campo com o Tab

if (event.willCommit || AFMergeChange(event).length === event.target.charLimit) {
        getField(“nome_do_campo”).setFocus();
    }

TOPICS
JavaScript , PDF forms
647
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Participant ,
Mar 22, 2023 Mar 22, 2023
LATEST

ok, as aspas curvas foi ao digitar no safari, no adobe não uso.

Já consegui fazer, tive que separar os dois scripts.

a parte do formato inseri no Script de formato personalizado

a parte do mudar de campo quando atigir o maximo inseri no Script de pressionamento de teclas personalizados

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 21, 2023 Mar 21, 2023

-Where did you put the code? Under what event?

-You have to only use straight quotes in your code, not curly ones.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 21, 2023 Mar 21, 2023

Coloquei em - Formatar - em seleciona categoria de formatos escolhi "personalizado".

Depois coloquei o codigo em: Script de formato personalizado.

 

Não compreendi sobre as aspas?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 21, 2023 Mar 21, 2023

> “nome_do_campo”

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 21, 2023 Mar 21, 2023

Moving to the next field works fine for me, but your formatting script is not good. It removes two digits from the value the user enters. You need to check if the length is 9, not 11. Also, you need to allow them to clear the field without getting an error message.

And if you want to reject a value you need to use the Validation event and set event.rc to false. Setting event.value to an empty string in the Format event doesn't remove the value the user entered, it just hides it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 22, 2023 Mar 22, 2023
LATEST

ok, as aspas curvas foi ao digitar no safari, no adobe não uso.

Já consegui fazer, tive que separar os dois scripts.

a parte do formato inseri no Script de formato personalizado

a parte do mudar de campo quando atigir o maximo inseri no Script de pressionamento de teclas personalizados

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines