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

質問編集履歴

4

htmlを追記いたしました。

2017/06/09 18:13

投稿

coco2
coco2

スコア9

title CHANGED
File without changes
body CHANGED
@@ -23,4 +23,12 @@
23
23
  {alert(str);}
24
24
  }
25
25
  </script>
26
- </head>
26
+ </head>
27
+ <body>
28
+ <div class="form">
29
+ <form action="cgi-bin/example.cgi" method="post" onkeyup="checkText(this)">
30
+ <p>検索したいキーワードを入力してください。</p>
31
+ <input type="text" name="search" placeholder="キーワードを入力" value="">
32
+ <input type="submit" name="submit" value="検索">
33
+ </form>
34
+ </div>

3

htmlを追記いたしました。

2017/06/09 18:13

投稿

coco2
coco2

スコア9

title CHANGED
File without changes
body CHANGED
@@ -2,13 +2,25 @@
2
2
  半角数字以外が含まれると「エラー」とアラートで表示されるようにしております。
3
3
  よろしくお願いいたします。
4
4
 
5
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6
+ <html lang="ja">
7
+ <head>
8
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
9
+ <meta name="keywords" content=" ">
10
+ <meta name="description" content=" ">
11
+ <meta http-equiv="content-style-type" content="text/css">
12
+ <meta http-equiv="content-script-type" content="text/javascript">
13
+ <link rel="stylesheet" href="style.css">
14
+ <link href="./style.css" rel="stylesheet" type="text/css">
15
+ <title> </title>
5
- <script type="text/javascript">
16
+ <script type="text/javascript">
6
- //関数 checkText の定義 (引数:テキストインプット)
17
+ //関数 checkText の定義 (引数:テキストインプット)
7
- function checkText(txt_obj){
18
+ function checkText(txt_obj){
8
- //テキストインプット内の入力値を変数化
19
+ //テキストインプット内の入力値を変数化
9
- var str ="エラー"
20
+ var str ="エラー"
10
- //入力値に 0~9 以外があれば
21
+ //入力値に 0~9 以外があれば
11
- if(str.match(/[^0-9]+/))
22
+ if(str.match(/[^0-9]+/))
12
- {
13
- alert(str);
23
+ {alert(str);}
14
- }
24
+ }
25
+ </script>
26
+ </head>

2

2017/06/09 18:07

投稿

coco2
coco2

スコア9

title CHANGED
File without changes
body CHANGED
File without changes

1

2017/06/09 17:48

投稿

coco2
coco2

スコア9

title CHANGED
File without changes
body CHANGED
File without changes