标题:求大神指教这个代码为什么总是不成功?来自《Web编程入门经典--HTML、XHTML ...
只看楼主
刘碗腾
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2013-11-17
 问题点数:0 回复次数:0 
求大神指教这个代码为什么总是不成功?来自《Web编程入门经典--HTML、XHTML和CSS(第2版)》
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.

<html xmlns="http://www. lang="en" xml:lang="en">

  <head>
    <meta http-equiv="Content-type" content="text/xhtml; charset=UTF-8" />
    <title>Checking Text Fields</title>
    <script type = "text/javascript">
    function validate(form) {
var returnValue = true;
var formElements = form.elements;
for (var i=0; i<formElements.length; i++)
{
currentElement = formElements[i];
if (currentElement.value=="" && currentElement.className=="required") {
alert("The required field \""+currentElement.name +"\" is empty. Please provide a value for it.");
currentElement.focus();
returnValue = false;
break;
}
return returnValue;
}
}
    </script>
    </head>
    <body>
    <form name="frmEnquiry" method="post" action="register.aspx" onsubmit="return validate(this);">
<div class="label"><label for="Name">Name:</label></div>
<div class="formElement">
<input type="text" class="required" name="Name" size="12" id="Name" />
</div>
<div class="label"><label for="E-mail">E-mail:</label></div>
<div class="formElement">
<input type="text" class="required" name="E-mail" size="12" id="E-mail" />
</div>
<div class="label"><label for="txtEmail">Please enter your query here:</label></div>
<div class="formElement">
<textarea rows="8" class="required" cols="30" name="Query" id="Query">
</textarea>
</div>
<div class="label"><label for="txtEmail">&nbsp;</label></div>
<div class="formElement">
<input type="submit" class="" value="Submit your query" />
</div>
</form>
    </body>
    </html>
搜索更多相关主题的帖子: javascript function 编程入门 content PUBLIC 
2013-11-17 21:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-423690-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013882 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved