@narem

Как остановить отправку формы?

<section id="sect-auth">
            <form action="" method="" id="form-authorization">
                <input type="text" placeholder="Логин" id="login" name="login">
				<span class="message"></span>
                <input type="password" placeholder="Пароль" id="password" name="password">
				<div id="button-auth">
					<input type="checkbox" name="unsave" id="unsave">
					<label for="unsave">Не мой компьютер</label>
				</div>
                <input type="submit" id="enter" value="Войти">
            </form>
        </section>


class Check{
	checkEmpty(){
		this.login = document.getElementById('login').value,
		this.passw = document.getElementById('password').value;
		if(!this.login && !this.passw){
			return false;
		}else{
			alert(`${this.login} and ${this.passw}`);
		}
	}
}

window.onload = function(){
	var check = new Check();
	document.getElementById('enter').onclick = function(){
		check.checkEmpty();
	}
}

НО форма все равно отправляется(в адресной строке появляется гет запрос), помогите, как остановить полностью отправку
  • Вопрос задан
  • 134 просмотра
Решения вопроса 1
@shevchenko__k
Помогаю новорожденным web программистам
поменяй
<input type="submit" id="enter" value="Войти">
на
<input type="button" id="enter" value="Войти">
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы