LoginSignup
1
1

More than 5 years have passed since last update.

HTML5とjQueryでrequiredでチェックを行った後、formをsubmitする

Last updated at Posted at 2018-05-18
  • requiredが動いた後、formをsubmitしています。
  • また、二重submitできないようにbuttonのdisabledをtrueにしています。
test.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <form method="post" id="hogeForm">
    <input type="text" name="hoge1" required>
    <input type="text" name="hoge2" required>
    <button type="submit" class="btn-send">送信</button>
  </form>
</body>
<script src="/js/jquery.min.js"></script>
<script>
  $(function() {
    $('#hogeForm').submit(function(e) {
      $('.btn-send').prop('disabled', true);
    });
  });
</script>
</html>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1