JavaScript的一些小问题 没看到调用该函数呀<input name= "validate1 " type= "text " size= "10 " maxlength= "4 " onblur="valid();" /> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你都没有调用valid()当然就没用了阿 还有楼主的html格式<form> <body></body></form> body在form里判断为空函数一般在<input type= "submit " name= "Submit " value= "登录 " />调用 <script language= "javascript "> function veri() { var sourcenum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "; var siglenum = " "; var checknum = " "; var index =0; var result = " "; for (i=0; i <8; i++) { //随机生成0-35个数字 index = (Math.random()*100)%35; //截取单个字符 siglenum=sourcenum.substring(index,index+1); checknum +=siglenum; i++; } document.form1.validation_txt.value = checknum; } <!-- function deal() { //获得一个字符串 result.innerHTML = veri(); } --> function valid() { if (document.form1.validate1.value == " ") { alert( "验证码不能为空! "); document.form1.validate1.focus(); return false; } if (document.form1.validate1.value != document.form1.validation_txt.value) { alert( "验证码错误! "); document.form1.validate1.focus(); return false; } else{document.location.href=""//跳到下个页面}} </script> </head> <form name= "form1" action=""> <body onload= "veri()"> <table width= "50% " height= "179 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 "> <tr> <td height= "28 " colspan= "2 "> <div align= "center " class= "STYLE1 "> 登陆页面 </div> </td> </tr> <tr> <td width= "33% " height= "37 "> <div align= "right "> 用户名: </div> </td> <td width= "67% "> <input name= "username " type= "text " id= "username " /> </td> </tr> <tr> <td height= "38 "> <div align= "right "> 密 码: </div> </td> <td> <input name= "password " type= "password " id= "password " /> </td> </tr> <tr> <td height= "38 "> <div align= "right "> 验证码: </div> </td> <td> <input name= "validate1 " type= "text " size= "10 " maxlength= "4 " /> <input type= "text " name= "validation_txt " size= "4 " maxlength= "4 " readonly= "true "/> </td> </tr> <tr> <td colspan= "2 "> <div align= "center "> <input type= "button " name= "Submit" value= "登录 " onclick="valid()"> </div> </td> </tr> </table> </body> </form></html> zoom(缩放)div与IE,Firefox的兼容 动态生成select option 的问题,做了一下午,明天要交,但实在是没有办法了,那位帮帮谢谢了 jquery 文本框值得变换 触发焦点,弹出提示对话框? 求浮动的广告在页面右侧固定,且随着屏幕的上移下移移动? select项目的导出!! 如何实现点击表格一行,使用服务器断脚本删除数据哭数据 ie5menu是什么对象? C#将图片输出流传入web端显示在Image控件里 ext中treenode点击事件 100分 Angularjs的ng-show控制显隐问题. 求js+xml生成下拉带二级导航条的代码 用js 怎样截取字符串?
function veri() {
var sourcenum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var siglenum = " ";
var checknum = " ";
var index =0;
var result = " ";
for (i=0; i <8; i++) {
//随机生成0-35个数字
index = (Math.random()*100)%35;
//截取单个字符
siglenum=sourcenum.substring(index,index+1);
checknum +=siglenum;
i++;
}
document.form1.validation_txt.value = checknum;
}
<!--
function deal() {
//获得一个字符串
result.innerHTML = veri();
}
-->
function valid() {
if (document.form1.validate1.value == " ") {
alert( "验证码不能为空! ");
document.form1.validate1.focus();
return false;
}
if (document.form1.validate1.value != document.form1.validation_txt.value) {
alert( "验证码错误! ");
document.form1.validate1.focus();
return false;
}
else{
document.location.href=""//跳到下个页面
}
}
</script>
</head>
<form name= "form1" action="">
<body onload= "veri()">
<table width= "50% " height= "179 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 ">
<tr>
<td height= "28 " colspan= "2 "> <div align= "center " class= "STYLE1 "> 登陆页面 </div>
</td>
</tr>
<tr>
<td width= "33% " height= "37 "> <div align= "right "> 用户名: </div> </td>
<td width= "67% "> <input name= "username " type= "text " id= "username " /> </td>
</tr>
<tr>
<td height= "38 "> <div align= "right "> 密 码: </div> </td>
<td> <input name= "password " type= "password " id= "password " /> </td>
</tr>
<tr>
<td height= "38 "> <div align= "right "> 验证码: </div> </td>
<td> <input name= "validate1 " type= "text " size= "10 " maxlength= "4 " />
<input type= "text " name= "validation_txt " size= "4 " maxlength= "4 " readonly= "true "/> </td>
</tr>
<tr>
<td colspan= "2 "> <div align= "center ">
<input type= "button " name= "Submit" value= "登录 " onclick="valid()">
</div> </td>
</tr>
</table>
</body>
</form>
</html>