やりたいこと
フォーム画面にエラーを表示したいです。
ログインIDまたはパスワードが違います。という表示が今のままでは、別の画面に表示されてしまいます。
alertではなく、<h1>業務報告システム</h1>の下に、ログインIDまたはパスワードが違います。と表示させたいです。
どのように変更したらいいのでしょうか。
java
1<script type="text/javascript"> 2<!-- 3 4 5 function formcheck(){ 6 var flag = 0; 7 8 //設定開始(必須にする項目を設定してください) 9 if(document.Form1.userId.value == ""){ 10 flag = 1; 11 document.getElementById('notice-input-1'); 12 } 13 else if(document.Form1.pass.value == ""){ 14 document.getElementById('notice-input-2'); 15 flag = 1; 16 } 17 18 if(flag){ 19 document.write('ログインIDまたはパスワードが違います。'); 20 return false; 21 } 22 else{ 23 return true; //送信を実行 24 25 } 26} 27 28// --> 29</script> 30<%@ page language="java" contentType="text/html; charset=UTF-8" 31 pageEncoding="UTF-8"%> 32<h1>業務報告システム</h1> 33</head> 34 <body> 35 <form name = "Form1" action="/gyomuhokoku/LoginServlet" method="post" onsubmit="return formcheck()"><br> 36 37 ユーザーID:<input type="text" name="userId" id="notice-input-1"> <br> 38 パスワード:<input type="text" name="pass" id="notice-input-2"> <br> 39 40 <button type=submit>ログイン</button> 41 </form> 42</body> 43</html>
回答2件
あなたの回答
tips
プレビュー