How to make an HTML function stop working with JavaScript?

0

I'd like that if allowSubmit is false, it would not execute the action of form ( action="logintest.php" ). How can I do this?

function check_if_capcha_is_filled (e) {
    if(allowSubmit)
        return true;
    else{
        alert('Fill in the capcha!');
        //Código aqui
    }
}

<form method="post" onsubmit="check_if_capcha_is_filled()" action="logintest.php">
    
asked by anonymous 10.05.2017 / 04:03

1 answer

2
function check_if_capcha_is_filled (e) {
    if(allowSubmit)
        return true;
    else{
        alert('Fill in the capcha!');
        return false;
    }
}
<form method="post" onsubmit="return check_if_capcha_is_filled()" action="logintest.php">

Only put the return in onsubmit and return false.

    
10.05.2017 / 04:22