teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

5

訂正

2018/03/09 00:13

投稿

MeB
MeB

スコア104

title CHANGED
File without changes
body CHANGED
@@ -7,12 +7,12 @@
7
7
  情報が少なくて申し訳ありませんが、
8
8
  よろしくお願いします。
9
9
 
10
-
10
+ 現在動いているコード(type="submit"をtype="button"にすると動かない)
11
11
  ```js
12
12
  <script src="js/jquery-3.3.1.min.js"></script>
13
13
  <script src="js/jquery.validate.min.js"></script>
14
- <script type="text/javascript">
14
+ <script type="text/javascript">
15
- $(function() {
15
+ $(function() {
16
16
  $("#form").validate({
17
17
  rules : {
18
18
  name: {
@@ -21,14 +21,14 @@
21
21
  }
22
22
  });
23
23
  });
24
- </script>
24
+ </script>
25
25
  ```
26
26
  ```html
27
- <form id="form" action="" method="post" name="form">
27
+ <form id="form" action="index.php" method="post" name="form">
28
- <p>会社名<span>(必須)</span></p>
28
+ <p>名</p>
29
- <input type="text" name="name" value="" class="">
29
+ <input type="text" name="name"/>
30
- <div class="submit"><button type="button" name="mode" value="confirm" id="btn_id"><img src="images/check.png" alt="送信"><span>確認画面</span></button></div>
30
+ <button type="submit"><img src="images/check.png" alt="送信"><span>確認画面</span></button>
31
- </form>
31
+ </form>
32
32
  ```
33
33
 
34
34
  追記

4

追記

2018/03/09 00:12

投稿

MeB
MeB

スコア104

title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,4 @@
1
+ [https://jqueryvalidation.org/](https://jqueryvalidation.org/)
1
2
  Validation Pluginを使ってみたのですが、
2
3
  全く反応してくれません。
3
4
  ほかのサイトのコピペでいいものは実際に動かしてみましたが正常に動作するので

3

訂正

2018/03/09 00:08

投稿

MeB
MeB

スコア104

title CHANGED
File without changes
body CHANGED
@@ -14,7 +14,7 @@
14
14
  $(function() {
15
15
  $("#form").validate({
16
16
  rules : {
17
- corp_name: {
17
+ name: {
18
18
  required: true
19
19
  }
20
20
  }
@@ -24,8 +24,8 @@
24
24
  ```
25
25
  ```html
26
26
  <form id="form" action="" method="post" name="form">
27
- <p>名<span>(必須)</span></p>
27
+ <p>会社名<span>(必須)</span></p>
28
- <input type="text" name="name" value="" class="">
28
+ <input type="text" name="name" value="" class="">
29
29
  <div class="submit"><button type="button" name="mode" value="confirm" id="btn_id"><img src="images/check.png" alt="送信"><span>確認画面</span></button></div>
30
30
  </form>
31
31
  ```

2

訂正

2018/03/08 13:02

投稿

MeB
MeB

スコア104

title CHANGED
File without changes
body CHANGED
@@ -11,18 +11,15 @@
11
11
  <script src="js/jquery-3.3.1.min.js"></script>
12
12
  <script src="js/jquery.validate.min.js"></script>
13
13
  <script type="text/javascript">
14
+ $(function() {
14
- $("form").validate({
15
+ $("#form").validate({
15
- rules : {
16
+ rules : {
16
- corp_name: {
17
+ corp_name: {
17
- required: true
18
+ required: true
19
+ }
18
20
  }
19
- },
20
- messages: {
21
- corp_name:{
22
- required: "必須項目です。"
23
- }
24
- }
25
21
  });
22
+ });
26
23
  </script>
27
24
  ```
28
25
  ```html

1

追記

2018/03/08 13:01

投稿

MeB
MeB

スコア104

title CHANGED
File without changes
body CHANGED
@@ -31,4 +31,10 @@
31
31
  <input type="text" name="name" value="" class="">
32
32
  <div class="submit"><button type="button" name="mode" value="confirm" id="btn_id"><img src="images/check.png" alt="送信"><span>確認画面</span></button></div>
33
33
  </form>
34
- ```
34
+ ```
35
+
36
+ 追記
37
+ type="button"
38
+ を削除すると動くのですが、type="button"
39
+ を使えるようにする方法はありますでしょうか。
40
+ 他の処理もあるためtype="submit"は使えません。