Problem with little java code

Hello,
I’m trying to validate an edit called CPF

The validation is working and the edit is filled with “invalid CPF” but the form is submitting the information even with a “return false”

Can you help me?

the function is inside the button’s Onclick()

export function button1_click ( event ) {
let cpf = $w ( ‘#input1’ ). value . replace ( “.” , “” ). replace ( “.” , “” ). replace ( “.” , “” ). replace ( “-” , “” )

// Elimina CPFs invalidos conhecidos 
**if**  ( cpf . length  !=  11  || 
    cpf  ==  "00000000000"  || 
    cpf  ==  "11111111111"  || 
    cpf  ==  "22222222222"  || 
    cpf  ==  "33333333333"  || 
    cpf  ==  "44444444444"  || 
    cpf  ==  "55555555555"  || 
    cpf  ==  "66666666666"  || 
    cpf  ==  "77777777777"  || 
    cpf  ==  "88888888888"  || 
    cpf  ==  "99999999999" ) { 
        $w ( '#input1' ). value  =  "CPF Inválido!" ; 
        **return**  **false** ; 
    } 
// Valida 1o digito  
**let**  add  =  0 ; 
**let**  i 
**for**  ( i  =  0 ;  i  <  9 ;  i ++) 
    add  +=  parseInt ( cpf . charAt ( i )) * ( 10  -  i ); 
**let**  rev  =  11  - ( add  %  11 ); 
**if**  ( rev  ==  10  ||  rev  ==  11 ) 
    rev  =  0 ; 
**if**  ( rev  !=  parseInt ( cpf . charAt ( 9 ))) { 
    $w ( '#input1' ). value  =  "CPF Inválido!" ; 
    **return**  **false** ; 
} 
// Valida 2o digito  
add  =  0 ; 
**for**  ( i  =  0 ;  i  <  10 ;  i ++) 
    add  +=  parseInt ( cpf . charAt ( i )) * ( 11  -  i ); 
rev  =  11  - ( add  %  11 ); 
**if**  ( rev  ==  10  ||  rev  ==  11 ) 
    rev  =  0 ; 
**if**  ( rev  !=  parseInt ( cpf . charAt ( 10 ))) { 
    $w ( '#input1' ). value  =  "CPF Inválido!" ; 
    **return**  **false** ; 
} 
**return**  **true** ; 

}

Use $w(‘#input1’).onCustomValdiation((value, reject) => {/here/})
See here . And put it inside the $w.onReady and not inside the button1_click event handler).

(P.S. it’s JavaScript. Java is completely different programming language).