HTMLでIncorrect use of <label for=FORM_ELEMENT>
phpで入力フォーム画面を作っています。
バリデーションのためのjavascriptが全く動かないので、デバッグツールを確認
したところ、1点気になるメッセージがありました。
それがタイトルのエラーです。
このエラーを調査したところ、HTMLのlabelタグのidと、inputタグのidが一致
しない場合に発生するようですが、ソースを確認したところ、発見できません
でした。
javascriptが全く動かない原因かはまだ不明ですが、問題の切り分けのためにも
このエラーをまず解消したいと思っています。
エラー原因をご教示いただければ幸いです。
ソースコードを添付します。
発生している問題・エラー
Incorrect use of <label for=FORM_ELEMENT>
該当するソースコード
<?php
session_start();
function generateToken()
{
$bytes = openssl_random_pseudo_bytes(16);
return bin2hex($bytes);
}
$token = generateToken();
$_SESSION['token'] = $token;
function escape($val)
{
return htmlspecialchars($val, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
?>
<!doctype html>
<html lang=ja>
<head>
<meta charset="utf-8">
<title>ユーザーメンテナンス(登録)</title>
<meta name="description" content="ユーザーの修正画面">
<!--リセットcss-->
<link rel="stylesheet" href="https://unpkg.com/ress/dist/ress.min.css">
<!--css-->
<link href="css/ad_style.css" rel="stylesheet">
<!--レスポンシブ対応-->
<meta name="viwport" content="width=device-width, initial-scale=1">
<!--Googleフォント-->
<link href="https://fonts.googleapis.com/css2?family=Sawarabi+Gothic&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@500&display=swap" rel="stylesheet">
</head>
<body>
<h1>ユーザーメンテナンス(登録)</h1>
<form action="?" method="post" class="usermente" id="usermente">
<input type="hidden" name="token" value="<?=$token?>">
<div id = "last_name">
<label for="sei">姓</label>
<input type="text" name="sei" id = "sei">
</div>
<div id = "first_name">
<label for="mei">名</label>
<input type="text" name="mei" id = "mei">
</div>
<div id="last_name_kana">
<label for="sei_kana">姓(カナ)</label>
<input type="text" name="sei_kana" id="sei_kana">
</div>
<div id="first_name_kana">
<label for="mei_kana">名(カナ)</label>
<input type="text" name="mei_kana" id="mei_kana">
</div>
<div id="user_name">
<label for="user">ユーザー</label>
<input type="text" name="user" id="user">
</div>
<div id="pass">
<label for="password">パスワード</label>
<input type="password" name="password" id="password">
</div>
<div id="pass2">
<label for="password2">パスワード(確認用)</label>
<input type="password" name="password2" id="password2">
</div>
<div class = "button_layout">
<input type="submit" class="button_b" name="button_re" id="button_re" value="戻る" formaction="user_table.php">
<input type="submit" class="button_b" name="button_con" id="button_con" value="確認" formaction="user_create_conf.php">
</div>
</form>
<?php require_once("user_chk_js.php"); ?>
</body>
</html>