自己写了一个js,但是最终不能控制住最后后的提交,前面的还是比较完美,大家看到后,能帮我解决一下吗?
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="Css/Main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> function Check( control ) { var userReg = /^[a-zA-Z0-9_]{1,}$/; var emailReg = /^.+@.+$/; var hiddValue = document.getElementById( "hiddValue" ); switch ( control.id ) { case "txt_user_LoginName": { var span_user_LoginName = document.getElementById( "span_user_LoginName" ); span_user_LoginName.innerHTML = ""; if ( control.value.length > 0 ) { if ( !control.value.match( userReg ) ) span_user_LoginName.innerHTML = "用户名格式不正确!"; else hiddValue.value = 1; } else span_user_LoginName.innerHTML = "此项不能为空!"; break; } case "txt_user_Password": { var span_user_LoginName = document.getElementById( "span_user_Password" ); span_user_Password.innerHTML = ""; if ( control.value.length > 0 ) { if ( !control.value.match( userReg ) ) span_user_Password.innerHTML = "密码格式不正确!"; else hiddValue.value = 1; } else span_user_LoginName.innerHTML = "密码不能为空!"; break; } case "txt_user_PasswordRel": { var txt_user_Password = document.getElementById( "txt_user_Password" ).value; var span_user_PasswordRel = document.getElementById( "span_user_PasswordRel" ); span_user_PasswordRel.innerHTML = ""; if ( control.value.length > 0 ) { if ( control.value != txt_user_Password ) span_user_PasswordRel.innerHTML = "两次输入密码不一样!"; else hiddValue.value = 1; } else span_user_PasswordRel.innerHTML = "密码不能为空!"; break; } case "txt_user_Email": { var span_user_Email = document.getElementById( "span_user_Email" ); span_user_Email.innerHTML = ""; if ( control.value.length > 0 ) { if ( !control.value.match( emailReg ) ) span_user_Email.innerHTML = "电子邮箱格式不正确!"; else hiddValue.value = 1; } else span_user_Email.innerHTML = "电子邮件不能为空!"; break; } default: } } function Empty( control ) { switch ( control.id ) { case "txt_user_LoginName": { var span_user_LoginName = document.getElementById( "span_user_LoginName" ); span_user_LoginName.innerHTML = "用户名只能由数字,字母及下划线组成。"; break; } case "txt_user_Password": { var span_user_Password = document.getElementById( "span_user_Password" ); span_user_Password.innerHTML = "密码只能由数字,字母及下划线组成"; break; } case "txt_user_PasswordRel": { var span_user_PasswordRel = document.getElementById( "span_user_PasswordRel" ); span_user_PasswordRel.innerHTML = "请再次输入密码!"; break; } case "txt_user_Email": { var span_user_Email = document.getElementById( "span_user_Email" ); span_user_Email.innerHTML = "请输入正确格式的电子邮箱"; break; } default: return false; } } function checkAll() { if ( checkEmpty() ) { if ( document.getElementById( "hiddValue" ).value == 1 ) { return true; } return false; } return false; } function checkEmpty() { var inputText = document.getElementsByTagName( "input" ); for ( var i = 0; i < inputText.length; i++ ) { if ( inputText[i].type == "text" ) if ( inputText[i].value.length < 0 || inputText[i].value.length == 0 ) return false; else return true; } } </script> </head> <body> <form id="form1" runat="server"> <table class="table "> <tr> <td class="labelCol "> 用户名: </td> <td> <input id="txt_user_LoginName" type="text" class="textInput" onblur="Check(this)" onfocus="Empty(this);" /><span id="span_user_LoginName" class="red">*</span> </td> </tr> <tr> <td class="labelCol "> 密码: </td> <td> <input id="txt_user_Password" type="text" class="textInput" onblur="Check(this)" onfocus="Empty(this);" /><span id="span_user_Password" class="red">*</span> </td> </tr> <tr> <td class="labelCol "> 重复密码: </td> <td> <input id="txt_user_PasswordRel" type="text" class="textInput" onblur="Check(this)" onfocus="Empty(this);" /><span id="span_user_PasswordRel" class="red">*</span> </td> </tr> <tr> <td class="labelCol "> 邮箱: </td> <td> <input id="txt_user_Email" type="text" class="textInput" onblur="Check(this)" onfocus="Empty(this);" /><span id="span_user_Email" class="red">*</span> </td> </tr> <tr style="text-align: center;"> <td colspan="2" style="text-align: center;"> <input id="hiddValue" type="hidden" value="0" /> <asp:Button ID="btn_Regist" runat="server" Text="注册" OnClick="btn_Regist_Click" OnClientClick="return checkAll();" /> </td> </tr> </table> </form> </body> </html>
联盟快卖 商人,生意人,待创业人士在此可以共赢互利 期待你的加入 群号:140809277
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗