statement if else not working

statement if else not working

I´ve done some tests, but couldn´t find out why, in the if-else statement below, the contents "123456789" get stuck in the field "MatrAgente" and cannot be changed on the form.


Follows the code (it is on the "on user input" action for the "MatrAgente" field)

if ( ((input.MatrAgente != "") && input.MatrAgente.matches("[0-9]{9}")) )  
{
     MatrAgente = "123456789" ;   
}
else 
{
     alert "else";
}