0
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript">
它是驗證碼如何從提交
function drawcap()
{
var captcha=Math.ceil(Math.random()*1000000);
document.getElementById("txtdraw").value=captcha;
}
提交表單
function validate()
{
var str1=document.getElementById('txtdraw');
var str2=document.getElementById('txtinput');
if(str1==str2){
return true;}
else{
alert("fill correct captcha");
return false;
}}
</script>
</head>
<body style="background-color: aliceblue">
形式提交,並驗證它
<form action="home.jsp" method="get" name="login" onsubmit="return validate();">
<fieldset style="align-self: center; height: 250px;">
<center><legend>login</legend></center>
<center><table style=" background-color: seashell; border:black; border-style: double; ">
<tr><td><label>Username</label></td>
<td><input type="text" name="username" required/></td>
<tr><td><label>Password</label></td>
<td><input type="password" name="password" required/></td></tr>
圖形驗證碼停止形式在這
<tr><td>Captcha</td><td><input type="text" readonly id="txtdraw"></td>
輸入用戶
<td><input type="text" id="txtinput" required=""/></td></tr>
<tr><td></td><td><input type="button" value="refresh" onclick="drawcap();" /></td></tr>
<tr><td><input type="submit" value="login"/></td>
<td><input type="reset" value="Reset"/><td></tr><br>
<tr><td><a href="#">New Here</a></td><td><a href="#">Forget Password</a></td></tr>
</table></center>
</fieldset>
</form>
</body>
</html>
抱歉..不明白 –
@ruchikajain希望你現在明白了。 –
是的理解..謝謝你。 –