regform_v0.2.js文件如下:var i, k = 0;
function changInfo(node, info, nColor){
node.nextSibling.nextSibling.firstChild.nodeValue = info;
node.nextSibling.nextSibling.style.color = nColor;
}
function checkNikeName(node){
if(node.value.length > 20 || node.value.length < 2)
changInfo(node, "您输入的昵称长度错误", "red");
changInfo(node,"√","blue");
}
function checkPsw(node){
if(node.value.length > 10 || node.value.length < 6)
changInfo(node, "您输入的密码长度错误", "red");
else if(!(/^[0-9a-zA-Z]+$/.test(node.value)))
changInfo(node, "您输入的密码含有除数字和字母以外的字符", "red");
else changInfo(node, "√", "blue");
}
function checkPsw2(node){
if(document.getElementById("pwd").value == node.value && node.value != "")
changInfo(node, "√", "blue");
else
changInfo(node, "重复密码错误", "red");
}
function checkEmail(node){
if(node.value.length <= 0)
changInfo(node, "未填写Email", "red");
else if(!(/^[_0-9a-zA-Z]+@([_0-9a-zA-Z]+\.)+[a-z]{2,3}$/.test(node.value)))
changInfo(node, "email格式错误", "red");
else changInfo(node, "√", "blue");
}
function checkUserName(node){
for(i = 0; i < users.length; i++){
if(node.value == users[i][1])
break;
}
if(i == users.length){
changInfo(node, "非本班级学生", "red");
else changInfo(node, "√", "blue");
}
function checkUserId(node){
if(document.regForm.username.value == "")
{
alert("请先填写姓名!");
node.value = "";
document.regForm.username.focus();
return false;
}
if(node.value == users[i][0]){
if(!ReadFile())
changInfo(node, "此学号已注册", "red");
else changInfo(node,"√", "blue");
}
else
changInfo(node, "学号填写错误", "red");}
function saveInfo(){
var sexTemp, strInfo;
if(document.regForm.sex[0].checked == true)
sexTemp = "女生";
else
sexTemp = "男生";
strInfo = document.getElementById("nikename").value + " " + document.getElementById("pwd").value + " " +
document.getElementById("username").value + " " + document.getElementById("userid").value + " " +
document.getElementById("email").value + " " + document.getElementById("city").options[document.getElementById("city").selectedIndex].text + " " +
sexTemp + " " + document.getElementById("birthmoth").options[document.getElementById("birthmoth").selectedIndex].text + " " +
document.getElementById("birthday").options[document.getElementById("birthday").selectedIndex].text + " " + document.getElementById("intro").value;
AppendFile(strInfo);
}
function AppendFile(strInfo){
var fso, ftxt, ForAppanding = 8, fileG;
fso = new ActiveXObject("Scripting.FileSystemObject");
ftxt = fso.OpenTextFile("e:\\luyinyan\\regInfo.txt", ForAppanding, false, -1);
ftxt.WriteLine(strInfo);
ftxt.Close();
fso = null;
}
function ReadFile(){
var fso, ftxt, str, strStuNum;
fso = new ActiveXObject("Scripting.FileSystemObject");
ftxt = fso.OpenTextFile("e:\\luyinyan\\regInfo.txt", 1, false, -1);
while(!ftxt.atEndOfStream)
{
str = ftxt.ReadLine();
strArray = str.split(" ");
if(strArray[3] == document.getElementById("userid").value)
{
ftxt.Close();
fso = null;
return false;
}
}
ftxt.Close(); fso = null;
return true;
}
function checkAll()
{
var objects = getElementsByTagName("span");
for(i = 0; i < objects.length; i++)
{
if(objects[i].firstChild.nodevalue != "√")
return false;
}
return true;
}
function endCheck(){
if(checkAll)
{
document.getElementById("reWrite").value = "确定";
document.getElementById("showInfo").innerHTML = "恭喜您,注册成功。";
saveInfo();
}
else
{
document.getElementById("reWrite").value = "修改信息";
document.getElementById("showInfo").innerHTML = "注册失败,您的信息填写有误。";
}
ChangeStatueSelect();
document.getElementById("overlay").style.display = "block";
document.getElementById("lightbox").style.display = "block";
}
function ChangeStatueSelect(){
selects = document.getElementsByTagName("select");
for(i = 0; i < selects.length; i++) {
if(selects[i].style.visibility != "hidden")
selects[i].style.visibility = "hidden";
else
{
selects[i].style.visibility = "visible";
window.location.reload();
}
}
}
function reWriteInfo(){
document.getElementById("overlay").style.display = "none";
document.getElementById("lightbox").style.display = "none";
ChangeStatueSelect();
}
function closeForm(){
window.close();
}
var users=[
["07109001","邬育幸","女"],
["07109002","曹凯茜","女"],
["07109003","陈淼", "女"],
["07109004","高丽萍","女"],
];为何出错,请帮忙!谢谢,万分感谢!!!由于论坛提问长度有限,所以.HTML文件和CSS部分代码就不贴出来了。如果需要请发邮件[email protected] 谢谢大家的帮助
function changInfo(node, info, nColor){
node.nextSibling.nextSibling.firstChild.nodeValue = info;
node.nextSibling.nextSibling.style.color = nColor;
}
function checkNikeName(node){
if(node.value.length > 20 || node.value.length < 2)
changInfo(node, "您输入的昵称长度错误", "red");
changInfo(node,"√","blue");
}
function checkPsw(node){
if(node.value.length > 10 || node.value.length < 6)
changInfo(node, "您输入的密码长度错误", "red");
else if(!(/^[0-9a-zA-Z]+$/.test(node.value)))
changInfo(node, "您输入的密码含有除数字和字母以外的字符", "red");
else changInfo(node, "√", "blue");
}
function checkPsw2(node){
if(document.getElementById("pwd").value == node.value && node.value != "")
changInfo(node, "√", "blue");
else
changInfo(node, "重复密码错误", "red");
}
function checkEmail(node){
if(node.value.length <= 0)
changInfo(node, "未填写Email", "red");
else if(!(/^[_0-9a-zA-Z]+@([_0-9a-zA-Z]+\.)+[a-z]{2,3}$/.test(node.value)))
changInfo(node, "email格式错误", "red");
else changInfo(node, "√", "blue");
}
function checkUserName(node){
for(i = 0; i < users.length; i++){
if(node.value == users[i][1])
break;
}
if(i == users.length){
changInfo(node, "非本班级学生", "red");
else changInfo(node, "√", "blue");
}
function checkUserId(node){
if(document.regForm.username.value == "")
{
alert("请先填写姓名!");
node.value = "";
document.regForm.username.focus();
return false;
}
if(node.value == users[i][0]){
if(!ReadFile())
changInfo(node, "此学号已注册", "red");
else changInfo(node,"√", "blue");
}
else
changInfo(node, "学号填写错误", "red");}
function saveInfo(){
var sexTemp, strInfo;
if(document.regForm.sex[0].checked == true)
sexTemp = "女生";
else
sexTemp = "男生";
strInfo = document.getElementById("nikename").value + " " + document.getElementById("pwd").value + " " +
document.getElementById("username").value + " " + document.getElementById("userid").value + " " +
document.getElementById("email").value + " " + document.getElementById("city").options[document.getElementById("city").selectedIndex].text + " " +
sexTemp + " " + document.getElementById("birthmoth").options[document.getElementById("birthmoth").selectedIndex].text + " " +
document.getElementById("birthday").options[document.getElementById("birthday").selectedIndex].text + " " + document.getElementById("intro").value;
AppendFile(strInfo);
}
function AppendFile(strInfo){
var fso, ftxt, ForAppanding = 8, fileG;
fso = new ActiveXObject("Scripting.FileSystemObject");
ftxt = fso.OpenTextFile("e:\\luyinyan\\regInfo.txt", ForAppanding, false, -1);
ftxt.WriteLine(strInfo);
ftxt.Close();
fso = null;
}
function ReadFile(){
var fso, ftxt, str, strStuNum;
fso = new ActiveXObject("Scripting.FileSystemObject");
ftxt = fso.OpenTextFile("e:\\luyinyan\\regInfo.txt", 1, false, -1);
while(!ftxt.atEndOfStream)
{
str = ftxt.ReadLine();
strArray = str.split(" ");
if(strArray[3] == document.getElementById("userid").value)
{
ftxt.Close();
fso = null;
return false;
}
}
ftxt.Close(); fso = null;
return true;
}
function checkAll()
{
var objects = getElementsByTagName("span");
for(i = 0; i < objects.length; i++)
{
if(objects[i].firstChild.nodevalue != "√")
return false;
}
return true;
}
function endCheck(){
if(checkAll)
{
document.getElementById("reWrite").value = "确定";
document.getElementById("showInfo").innerHTML = "恭喜您,注册成功。";
saveInfo();
}
else
{
document.getElementById("reWrite").value = "修改信息";
document.getElementById("showInfo").innerHTML = "注册失败,您的信息填写有误。";
}
ChangeStatueSelect();
document.getElementById("overlay").style.display = "block";
document.getElementById("lightbox").style.display = "block";
}
function ChangeStatueSelect(){
selects = document.getElementsByTagName("select");
for(i = 0; i < selects.length; i++) {
if(selects[i].style.visibility != "hidden")
selects[i].style.visibility = "hidden";
else
{
selects[i].style.visibility = "visible";
window.location.reload();
}
}
}
function reWriteInfo(){
document.getElementById("overlay").style.display = "none";
document.getElementById("lightbox").style.display = "none";
ChangeStatueSelect();
}
function closeForm(){
window.close();
}
var users=[
["07109001","邬育幸","女"],
["07109002","曹凯茜","女"],
["07109003","陈淼", "女"],
["07109004","高丽萍","女"],
];为何出错,请帮忙!谢谢,万分感谢!!!由于论坛提问长度有限,所以.HTML文件和CSS部分代码就不贴出来了。如果需要请发邮件[email protected] 谢谢大家的帮助
解决方案 »
- javascript实现用户连续回答多个问题,同时显示用户耗时
- 在第一个和第二个文本框中各输入1个数,点击右边的button,将最大值输出到第三个文本框,我写的程序哪出问题了
- 坐等:内嵌的js文件中怎么得到当前div容器的ID值
- 【100分求助】如何遍历一个Table的每一行,当行里有某个 td的内容为空的时候隐藏掉整个行?
- 求一正则表达式
- window.showModalDialog 弹出窗使用history.back()IE下没有效果,火狐可以,求大神指点
- innerHtml的问题,请大家帮帮忙!
- 怎样通过一个input的对象获取该对象的焦点
- 请问ASP中JAVAscript的变量传递
- 如何利用preventDefault 防止input重复内容提交
- javascript操作excel的一个小问题
- 框架跳转的问题
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>regForm</title>
<script type="text/javascript">
/*************************************************************************************************
*程序名称:注册表单示例程序
*程序版本:V1.0
*版本说明:期中作品
*作者:杭电软职07级卢银燕
**************************************************************************************************/
</script>
<link rel = "stylesheet" type = "text/css" href = "show.css">
<script language = "javaScript" src = "regform_v0.2.js">
</script>
</head>
<body>
<h2>用户注册表单示例 V1.0</h2>
<form name="regForm">
<fieldset>
<legend>注册信息</legend>
<label for="nikename">呢 称</label>
<input type="text" name="nikename" id="nikename" size="20" onBlur = "checkNikeName(this)">
<span class="required">*妮称在1-10个字之间</span><br/>
<label for="pwd">密 码</label>
<input type="password" name="pwd" id="pwd" size="21" onblur = "checkPsw(this)"/>
<span class="required">*密码在6-10个数之间,可以为数字和字母的组合</span><br/>
<label for="pwd2">重复密码</label>
<input type="password" name="pwd2" id="pwd2" size="21" onblur = "checkPsw2(this)"/>
<span class="required">*</span><br/>
<label for="username">真实姓名</label>
<input type="text" name="username" id="username" size="20" onblur = "checkUserName(this)"/>
<span class="required">*请正确填写您的真实姓名</span><br/>
<label for="userid">学 号</label>
<input type="text" name="userid" id="userid" size="20" onblur = "checkUserId(this)"/>
<span class="required">*请正确填写您的学号,一个学号只能注册一次</span><br/>
<label for="email">Email </label>
<input type="text" name="email" id="email" size="20" onblur = "checkEmail(this)"/>
<span class="required">*请正确填写您的Email信息</span><br/>
</fieldset>
<p>
<fieldset>
<legend>个人信息</legend>
<label for="city">来自哪里:</label>
<select name="city" id="city">
<option>杭州</option>
<option>宁波</option>
<option>温州</option>
</select>
<label>性别:</label>
<input type = "radio" name = "sex" id = "girl" checked="checked"/><label for = "girl">女生</label>
<input type = "radio" name = "sex" id = "boy"/><label for = "boy">男生</label>
<label>生日:</label>
<select name = "birthmoth" id = "birthmoth">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option><select>
<select name = "birthday" id = "birthday">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option></select>
<p>
<label for="intro">自我介绍:</label><br/>
<textarea name="intro" id="intro" cols="60" rows="10" /></textarea>
</fieldset>
<p>
<fieldset>
<legend>是否保留cookie信息</legend>
<input type="radio" name="saveType" id="nerver"/><label for="nerver">不保留</label>
<input type="radio" name="saveType" id="once" checked="checked"/><label for="once">保留一次</label>
<input type="radio" name="saveType" id="forever"/><label for="forever">永久保留</label>
</fieldset>
<p align = 'center'>
<input type="button" value="提交注册" onclick = "endCheck()"/>
<input type="reset" value="重新填写" onclick = "window.location.reload()"/>
</form>
<script language = "javaScript">
document.regForm.nikename.focus();
</script>
<div id = "overlay">
</div>
<div id = "lightbox">
<form>
<div id = "showInfo"> </div>
<input type = "button" value = "修改信息" id = "reWrite" size = "10" onclick = "reWriteInfo()"/>
</form>
</div>
</body>
</html>这是我的HTML文件
.required {color:blue}#lightbox {/*该层为高亮显示层*/
BORDER-RIGHT: #fff 1px solid;
BORDER-TOP: #fff 1px solid;
DISPLAY: none;
Z-INDEX: 9999; /*设置该层在网页的最上端,设置足够大*/
BACKGROUND: #fdfce9; /*设置背景色*/
LEFT: 50%;
MARGIN: -220px 0px 0px -250px;
BORDER-LEFT: #fff 1px solid;
WIDTH: 500px;
BORDER-BOTTOM: #fff 1px solid;
POSITION: absolute;
TOP: 50%;
HEIGHT: 300px;
TEXT-ALIGN: left;
border: 16px solid orange;
}
#overlay {/*该层为覆盖层*/
DISPLAY: none;
Z-INDEX: 9998; /*设置高亮层的下方*/
FILTER: alpha(opacity=50); /*设置成透明*/
LEFT: 0px;
WIDTH: 1000px;
POSITION: absolute;
TOP: 0px;
HEIGHT: 1000px;
BACKGROUND-COLOR: #000;
moz-opacity: 0.8;
opacity: .80
}#reWrite{
display: block;
position: relative;
top: 200px;
left: 200px;
color:red;
width: 80px;
} #showInfo{
display:block;
position:relative;
top:100px;
left:100px;
font-size:20px;
font-weight:bold;
color:orange;
}
建议你断点调试吧
vs20051:IE-右键属性-高级-去掉禁止脚本调试和禁用脚本调试(其他)前面的勾
2:必须将Javascript代码写在js文件中(因为aspx页面不支持插入断点)
3:利用<script language="javascript" src="javascript.js"></script>
将js文件包含进来
你下次发贴子的时候记得用编辑器上的"插入源代码"这个标签格式化你的信息,要不帮你调试时还的先把csdn加上的空格去掉
var i, k = 0;
function changInfo(node, info, nColor){
node.nextSibling.nextSibling.firstChild.nodeValue = info;
node.nextSibling.nextSibling.style.color = nColor;
}
function checkNikeName(node){
if(node.value.length > 20 || node.value.length < 2)
changInfo(node, "您输入的昵称长度错误", "red");
changInfo(node,"√","blue");
}
function checkPsw(node){
if(node.value.length > 10 || node.value.length < 6)
changInfo(node, "您输入的密码长度错误", "red");
else if(!(/^[0-9a-zA-Z]+$/.test(node.value)))
changInfo(node, "您输入的密码含有除数字和字母以外的字符", "red");
else changInfo(node, "√", "blue");
}
function checkPsw2(node){
if(document.getElementById("pwd").value == node.value && node.value != "")
changInfo(node, "√", "blue");
else
changInfo(node, "重复密码错误", "red");
}
function checkEmail(node){
if(node.value.length <= 0)
changInfo(node, "未填写Email", "red");
else if(!(/^[_0-9a-zA-Z]+@([_0-9a-zA-Z]+\.)+[a-z]{2,3}$/.test(node.value)))
changInfo(node, "email格式错误", "red");
else changInfo(node, "√", "blue");
}
function checkUserName(node){
for(i = 0; i < users.length; i++){
if(node.value == users[i][1])
break;
}
if(i == users.length)
changInfo(node,"非本班级学生", "red");
else changInfo(node, "√", "blue");
}
function checkUserId(node){
if(document.regForm.username.value == "")
{
alert("请先填写姓名!");
node.value = "";
document.regForm.username.focus();
return false;
}
if(node.value == users[i][0]){
if(!ReadFile())
changInfo(node, "此学号已注册", "red");
else changInfo(node,"√", "blue");
}
else
changInfo(node, "学号填写错误", "red"); }
function saveInfo(){
var sexTemp, strInfo; if(document.regForm.sex[0].checked == true)
sexTemp = "女生";
else
sexTemp = "男生";
strInfo = document.getElementById("nikename").value + " " + document.getElementById("pwd").value + " " +
document.getElementById("username").value + " " + document.getElementById("userid").value + " " +
document.getElementById("email").value + " " + document.getElementById("city").options[document.getElementById( "city").selectedIndex].text + " " +
sexTemp + " " + document.getElementById("birthmoth").options[document.getElementById("birthmoth ").selectedIndex].text + " " +
document.getElementById("birthday").options[document.getElementById("birthday").selectedIndex].text + " " + document.getElementById("intro").value;
AppendFile(strInfo);
}
function AppendFile(strInfo){
var fso, ftxt, ForAppanding = 8, fileG;
fso = new ActiveXObject("Scripting.FileSystemObject");
ftxt = fso.OpenTextFile("e:\\luyinyan\\regInfo.txt", ForAppanding, false, -1);
ftxt.WriteLine(strInfo);
ftxt.Close();
fso = null;
}
function ReadFile(){
var fso, ftxt, str, strStuNum;
fso = new ActiveXObject("Scripting.FileSystemObject");
ftxt = fso.OpenTextFile("e:\\luyinyan\\regInfo.txt", 1, false, -1);
while(!ftxt.atEndOfStream)
{
str = ftxt.ReadLine();
strArray = str.split(" ");
if(strArray[3] == document.getElementById("userid").value)
{
ftxt.Close();
fso = null;
return false;
}
}
ftxt.Close(); fso = null;
return true;
}
function checkAll()
{
var objects = document.getElementsByTagName("span");
for(i = 0; i < objects.length; i++)
{
if(objects[i].firstChild.nodevalue != "√")
return false;
}
return true;
}
function endCheck(){
if(checkAll()) //=================这里调用checkAll()函数时没有加括号=====================
{
document.getElementById("reWrite").value = "确定";
document.getElementById("showInfo").innerHTML = "恭喜您,注册成功。";
saveInfo();
}
else
{
document.getElementById("reWrite").value = "修改信息";
document.getElementById("showInfo").innerHTML = "注册失败,您的信息填写有误。";
}
ChangeStatueSelect();
document.getElementById("overlay").style.display = "block";
document.getElementById("lightbox").style.display = "block";
}
function ChangeStatueSelect(){
selects = document.getElementsByTagName("select");
for(i = 0; i < selects.length; i++) {
if(selects[i].style.visibility != "hidden")
selects[i].style.visibility = "hidden";
else
{
selects[i].style.visibility = "visible";
window.location.reload();
}
}
}
function reWriteInfo(){
document.getElementById("overlay").style.display = "none";
document.getElementById("lightbox").style.display = "none";
ChangeStatueSelect();
}
function closeForm(){
window.close();
}
var users=[
["07109001","邬育幸","女"],
["07109002","曹凯茜","女"],
["07109003","陈淼", "女"],
["07109004","高丽萍","女"]//=================这里多了个逗号==================
];