И я использовал для извлечения данных из формы на скрипте ps1 и веб-сервисах с кодом php, поэтому запрос страницы требует времени. На этот раз пользователи нажимают кнопку снова и снова.
Я пробую событие щелчка jQuery, но отправка формы остановлена.
myHTML файл:
<!doctype html>
<html lang = "en">
<head>
<meta charset = "utf-8">
<meta name = "viewport" content = "width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name = "description" content = "">
<meta name = "author" content = "">
<link rel = "icon" href = "favicon.ico">
<title>xxx</title>
<script
src = "https://code.jquery.com/jquery-3.3.1.min.js"
integrity = "sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8 = "
crossorigin = "anonymous"></script>
<script type = "text/javascript" src = "js/guncelle.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<!-- Bootstrap core CSS -->
<link href = "css/bootstrap.min.css" rel = "stylesheet">
<!-- Custom styles for this template -->
<link href = "css/style.css" rel = "stylesheet">
</head>
<div class = "bg"></div>
<body class = "text-center bg body3">
<div class = "cover-container d-flex h-100 p-3 mx-auto flex-column">
<header class = "masthead">
<div class = "inner">
<!--<h3 class = "masthead-brand"><img src = "image/xxx.png" style = "width: 100px;height: 100px"></h3>-->
<nav class = "navbar navbar-expand-sm navbar-dark justify-content-center">
<ul class = "navbar-nav">
<li class = "nav-item ">
<a class = "nav-link" href = "index.php">xxx</a>
</li>
<li class = "nav-item">
<a class = "nav-link" href = "sifirla.php">Sıfırla</a>
</li>
<li class = "nav-item active">
<a class = "nav-link" href = "guncelle.php">Güncelle</a>
</li>
</ul>
</nav>
</div>
</header>
<div><img src = "image/xxx.png" alt = "xxx" style = "width: 150px;height: 150px;"></div>
<div>
<?php echo $result; ?>
</div>
<main role = "main" class = "inner cover">
<form id = "form1" name = "form1" method = "POST" action = "guncelle.php" >
<div class = "form-group">
<label for = "uname">Kullanıcı Adınız:</label>
<input type = "text" class = "form-control" id = "uname" name = "uname" >
</div>
<span id = "unametxt" name = "unametxt" class = "required"></span>
<div class = "form-group">
<label for = "password">Mevcut Şifreniz:</label>
<input type = "password" class = "form-control" id = "password" name = "password">
</div>
<span id = "passwordtxt" name = "passwordtxt" class = "required"></span>
<div class = "form-group">
<label for = "newPassword">Yeni Şifreniz:</label>
<input type = "password" class = "form-control" id = "newPassword" name = "newPassword" maxlength = "15">
</div>
<span id = "newPasswordtxt" name = "newPasswordtxt" class = "required"></span>
<div class = "form-group">
<label for = "new2Password">Yeni Şifreniz Tekrar:</label>
<input type = "password" class = "form-control" id = "new2Password" name = "new2Password" maxlength = "15">
</div>
<span id = "new2Passwordtxt" name = "new2Passwordtxt" class = "required"></span>
<!--<div class = "form-group">
<div class = "g-recaptcha" data-sitekey = "6LdLWVsUAAAAANupQHCmg_28mFmc__o6ZwybziOK"></div>
</div>
-->
<p><input class = "btn btn-lg btn-guncelle" type = "submit" id = "Submit1" name = "Submit1" value = "Şifremi Güncelle" ></p>
</form>
</main>
<footer class = "mastfoot mt-auto">
<div class = "inner">
<p>@2018 <a href = "xxxx" target = "_blank">xxxx</a></p>
</div>
</footer>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src = "js/popper.min.js"></script>
<script src = "js/bootstrap.min.js"></script>
</body>
</html>
Когда эта форма была отправлена, я управлял стороной php следующим образом:
if (isset($_POST['Submit1'])) {
а затем я использую эти данные с веб-сервисом, в соответствии с тем, что я запустил скрипт ps1. Наконец, я показываю предупреждение об ошибке формы или успехе всего процесса.
Я хочу отключить кнопку при отправке формы. Как я могу это сделать?
это не связано с php, это нужно делать с помощью javascript. см. соответствующий вопрос для ответа



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Для этого вы можете использовать событие onsubmit в форме. Пожалуйста, добавьте событие onSubmit в форму, как показано ниже
<form id = "form1" name = "form1" method = "POST" action = "" onsubmit = "$('#Submit1').attr('disabled', 'disabled'); return true;">
эта кнопка отключена на мгновение. Но отправка формы не работает.
Хорошо, тогда вы можете скрыть эту кнопку, а не отключать ее
Попробуйте с этим кодом
<input class = "btn btn-lg btn-guncelle" type = "submit" id = "Submit1" name = "Submit1" value = "Şifremi Güncelle">
<script>
$(document).ready(function(){
$('#form1').on('submit',function(e){
e.preventDefault();
$('#submit1').prop('disabled','disabled');
});
});
</script>
Возможный дубликат Как предотвратить многократную отправку формы со стороны клиента?