Javascript运行时错误:无法获取未定义或空引用的属性'onsubmit'并保存按钮不会在cliking上触发 [英] Javascript runtime error: unable to get property 'onsubmit' of undefined or null reference and save button not firing on cliking
问题描述
引用:得到此错误无法理解为什么它会在页面加载时出现并保存按钮在我点击它时不会触发。请提前帮助谢谢
JavaScript运行时错误:无法获取未定义或空引用代码的属性'onsubmit':
<%@ Page Language =vbAutoEventWireup =falseCodeBehind =ChangePassword.aspx.vb
Inherits =PRCManagementConsole.Web。 ChangePassword%>
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。 DTD>
< html xmlns =http://www.w3.org/1999/xhtml>
< head id =Head1runat =server>
< link rel =stylesheettype =text / csshref =../ css / cbre_wsm_screen.css/>
< link rel =stylesheettype =text / csshref =../ css / BodyFramePages.css/>
< title>更改密码< / title>
< script src =../ Scripts / jquery-1.4.4.min.jstype =text / javascript/>
< style type =text / css>
.style2
{
宽度:97px;
}
.style3
{
宽度:330px;
}
< / style>
< / head>
< body>
< form id =form1runat =server>
< asp:ScriptManager ID =ScriptManager1runat =server>
< / asp:ScriptManager>
< script type =text / javascript>
function checknewtextbox(){
// debugger
var pass = document.getElementById(<%= txtNewPassword.ClientID%>);
var filter = /^(?=.*[az])(?=.*[$@$!%*?&])[A-Za-z\d$@$!%* ?&安培;] {8,20} /;
//调试器;
if(pass.value!=''){
if(!filter.test(pass.value)){
alert('密码必须至少包含最少8个字符和最多20个字符) 1个小写字母,1个数字和1个特殊字符');
pass.focus();
document.getElementById(<%= txtNewPassword.ClientID%>)。value ='';
返回false;
}
其他
返回true;
}
else返回true;
}
< / script>
< div id =page_wrapper>
< div id =wrapper_login_panel>
< div id =center_login_panel>
< table style =width:100%; ID = maintable >
<% - < tr style =height:33px> - %>
<% - < / tr> - %>
< tr>
< td class =style2> < / td>
<% - < td class =style1>
< / td> - %>
< td style =vertical-align:left; text-align:left;类= 节日礼物 >
< a href =http://www.cbre.com.au/title =CBRE Home>
< img id =img1runat =serversrc =../ images / cbre_pulseresponse_logo.pngalt =CBRE Pulse Responsewidth =280/>
< / a>
< / td>
< td colspan =2>
< div ID =ChangePassword>
< h1 style =width:327px; left:0px; top:0px;>
更改密码< / h1>
< br />
< table cellpadding =0cellspacing =0style =width:100%; margin:2px;>
< tr ID =trRowlabelrunat =server
style =height:0px; margin:0px; padding:0px 0px 0px 0px;>
< td align =centercolspan =2style =color:#393; padding:0px 0px 10px 0px;>
< asp:Label ID =lblmsgrunat =serverText =Visible =true/>
< / td>
< / tr>
< tr style =height:20px; margin:0px;>
< td align =leftstyle =padding:1px 1px 1px 50px;>
用户ID:
< / td>
< td style =padding:0>
< asp:TextBox ID =txtUserIdrunat =serverMaxLength =30
ToolTip =输入您的用户IDWidth =160pxReadOnly =true>< / ASP:文本框>
< / td>
< / tr>
< tr style =height:20px; margin:0px;>
< td align =leftstyle =padding:1px 1px 1px 50px;>
旧密码:
< / td>
< td style =padding:0>
< asp:TextBox ID =txtOldPasswordrunat =serverCausesValidation =True
MaxLength =20TextMode =PasswordToolTip =请输入您的旧密码
宽度=160px>< / asp:TextBox>
< / td>
< / tr>
< tr>
< td align =leftstyle =padding:1px 1px 1px 50px ;;>
新密码:
< / td>
< td style =padding:0>
< asp:TextBox ID =txtNewPasswordrunat =serverMaxLength =20onchange =return checknewtextbox();
TextMode =密码工具提示=请输入您的新密码Width =160px>< / asp:TextBox>
< / td>
< / tr>
< tr>
< td align =leftstyle =padding:1px 1px 1px 50px;>
确认密码:
< / td>
< td style =padding:0>
< asp:TextBox ID =txtConfirmPasswordrunat =serverMaxLength =20
TextMode =PasswordToolTip =请确认密码Width =160px>< / ASP:文本框>
< / td>
< / tr>
< tr>
< td align =leftstyle =padding:1px 1px 1px 50px;>
< / td>
< td align =leftcolspan =2style =padding:0px 0px 0px 0px;>
< asp:Button ID =btnSaverunat =serverText =Save/>
<% - <触发器>
< asp:AsyncPostBackTrigger ControlID =btnSaveEventName =Click/>
< / Triggers> - %>
< / td>
< / tr>
< tr>
< td align =leftcolspan =2style =padding:1px 1px 1px 50px;>
< asp:Literal ID =litMessagerunat =server>< / asp:Literal>
< / td>
< / tr>
< / table>
< / div>
< / td>
< / tr>
< / table>
< / div>
< / div>
< / div>
< / form>
< / body>
< / html>
后端代码
< pre lang =HTML>进口PRC.BO
进口PRC.DTO
进口DTO
进口System.Web.Security
进口System.Data.SqlClient
进口System.Configuration
导入DAL.Contacts
公共类ChangePassword
继承System.Web.UI.Page
受保护的子Page_Load(ByVal sender As Object ,ByVal e As System.EventArgs)处理Me.Load
如果Session(temp)IsNot Nothing则
如果Session(temp)= True则
lblmsg.Visible = True
lblmsg.ForeColor = Drawing.Color.Red
lblmsg.Text =首次登录!请更改密码
Session.Remove(temp)
结束如果
Else
lblmsg.Visible = False
trRowlabel.Visible = False
End if
If Request.QueryString(Name)IsNot Nothing Then
txtUserId.Text = Request.QueryString(Name)
End if
End Sub
Protected Sub btnSave_Click(sender as Object,e As EventArgs)处理btnSave.Click
litMessage.Text =
如果txtUserId.Text.Trim.Length = 0则
litMessage.Text = litMessage.Text +< a style = font-weight: normal; font-size:10pt; color: red > 请输入用户ID
txtUserId.Focus()
结束如果
如果txtOldPassword.Text.Trim.Length = 0那么
litMessage.Text = litMessage.Text +< / br > < a style = font-weight: normal; font-size:10pt; 颜色: 红色 > 请输入旧密码< / a >
txtOldPassword.Focus()
结束如果
如果txtNewPassword .Text.Trim.Length = 0然后
litMessage.Text = litMessage.Text +< / br > < a style = font-weight: 正常; font-size:10pt; co lor: red > 请输入新密码< / a > ;
txtNewPassword.Focus()
结束如果
如果txtConfirmPassword.Text.Trim.Length = 0那么
litMessage.Text = litMessage。文字+< / br > < a 样式 = font-weight: normal; font-大小:10pt; color: red > 请输入确认密码< / a >
txtConfirmPassword.Focus()
结束如果
如果不是(txtNewPassword.Text.Trim()= txtConfirmPassword.Text.Trim())那么
litMessage .Text = litMessage.Text +< / br > < a style = 字体重量: normal; font-size:10pt; color: red > 新&确认密码不匹配< / a >
txtConfirmPassword.Focus()
结束如果
如果不是(litMessage.Text =)那么
退出Sub
结束如果
如果String.Equals(txtOldPassword.Text,txtNewPassword.Text)那么
litMessage.Text =< / br > < a style = font-weight: normal; font-size:10pt; 颜色: 红色 > 旧密码和新密码不能相同< / a >
退出Sub
结束如果
Dim userPwd As New UserPassword
Dim i As Integer = PRC.DTO.PRCContractor.Queries.PRC_AdminChangePassword(txtUserId.Text,userPwd.EncryptPassword(txtOldPassword.Text),userPwd.EncryptPassword(txtNewPassword.Text))
If(i = 1)然后
Dim MyScript As String =alert('密码已成功更新!请再次登录!'); window.location ='/ LOGin.aspx';
ScriptManager.RegisterClientScriptBlock(Page,Page.GetType(),MyScript,MyScript,True)
ElseIf( i = 3)然后
litMessage.Text =< a 样式 = font-weight: normal; font-size:10pt; 颜色: red > 旧密码不正确< / a >
txtOldPassword.Focus()
否则
litMessage.Text =< a style = font-weight: < span class =code-attribute> normal; font-size:10pt; < span class =code-attribute> color: red > 无效的用户ID < / a >
txtUserId.Focus()
结束如果
结束次级
结束等级
我尝试了什么:
收到此错误不能理解为什么它会在页面加载时保存,并且当我点击它时保存按钮不会触发。请帮助提前感谢
JavaScript运行时错误:无法获取未定义或空引用代码的属性'onsubmit' : @
!%*?&])[A-Za- z\d
@
Quote:getting this error not able to understand why it is coming when the page loads and save button not firing when i clicks it.please help thanks in advance
JavaScript runtime error: Unable to get property 'onsubmit' of undefined or null reference code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="ChangePassword.aspx.vb" Inherits="PRCManagementConsole.Web.ChangePassword" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <link rel="stylesheet" type="text/css" href="../css/cbre_wsm_screen.css" /> <link rel="stylesheet" type="text/css" href="../css/BodyFramePages.css" /> <title>Change Password</title> <script src="../Scripts/jquery-1.4.4.min.js" type="text/javascript"/> <style type="text/css"> .style2 { width: 97px; } .style3 { width: 330px; } </style> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <script type="text/javascript"> function checknewtextbox() { //debugger var pass = document.getElementById("<%=txtNewPassword.ClientID %>"); var filter = /^(?=.*[a-z])(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,20}/; // debugger; if (pass.value != '') { if (!filter.test(pass.value)) { alert('Password Must contain Minimum 8 and Maximum 20 characters at least 1 Lowercase Alphabet, 1 Number and 1 Special Character'); pass.focus(); document.getElementById("<%=txtNewPassword.ClientID %>").value = ''; return false; } else return true; } else return true; } </script> <div id="page_wrapper"> <div id="wrapper_login_panel"> <div id="center_login_panel"> <table style="width: 100%;" id="maintable"> <%-- <tr style="height:33px">--%> <%--</tr>--%> <tr> <td class="style2"> </td> <%--<td class="style1"> </td>--%> <td style="vertical-align: left; text-align: left;" class="style3"> <a href="http://www.cbre.com.au/" title="CBRE Home"> <img id="img1" runat="server" src="../images/cbre_pulseresponse_logo.png" alt="CBRE Pulse Response" width="280" /> </a> </td> <td colspan="2"> <div ID="ChangePassword" > <h1 style="width: 327px; left: 0px; top: 0px;"> Change Password</h1> <br /> <table cellpadding="0" cellspacing="0" style="width:100%; margin:2px;"> <tr ID="trRowlabel" runat="server" style="height:0px; margin:0px;padding: 0px 0px 0px 0px;"> <td align="center" colspan="2" style="color: #393;padding: 0px 0px 10px 0px;"> <asp:Label ID="lblmsg" runat="server" Text="" Visible="true" /> </td> </tr> <tr style="height:20px; margin:0px;"> <td align="left" style="padding: 1px 1px 1px 50px;"> User Id: </td> <td style="padding: 0"> <asp:TextBox ID="txtUserId" runat="server" MaxLength="30" ToolTip="Enter your User Id" Width="160px" ReadOnly="true"></asp:TextBox> </td> </tr> <tr style="height:20px; margin:0px;"> <td align="left" style="padding: 1px 1px 1px 50px; "> Old Password: </td> <td style="padding: 0"> <asp:TextBox ID="txtOldPassword" runat="server" CausesValidation="True" MaxLength="20" TextMode="Password" ToolTip="Please Enter your Old password" Width="160px"></asp:TextBox> </td> </tr> <tr> <td align="left" style="padding: 1px 1px 1px 50px;;"> New Password: </td> <td style="padding: 0"> <asp:TextBox ID="txtNewPassword" runat="server" MaxLength="20" onchange ="return checknewtextbox();" TextMode="Password" ToolTip="Please Enter your New password" Width="160px"></asp:TextBox> </td> </tr> <tr> <td align="left" style="padding: 1px 1px 1px 50px;"> Confirm Password: </td> <td style="padding: 0"> <asp:TextBox ID="txtConfirmPassword" runat="server" MaxLength="20" TextMode="Password" ToolTip="Please confirm password" Width="160px"></asp:TextBox> </td> </tr> <tr> <td align="left" style="padding: 1px 1px 1px 50px;"> </td> <td align="left" colspan="2" style="padding: 0px 0px 0px 0px;"> <asp:Button ID="btnSave" runat="server" Text="Save" /> <%-- <Triggers> <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click"/> </Triggers>--%> </td> </tr> <tr> <td align="left" colspan="2" style="padding: 1px 1px 1px 50px;"> <asp:Literal ID="litMessage" runat="server"></asp:Literal> </td> </tr> </table> </div> </td> </tr> </table> </div> </div> </div> </form> </body> </html>
backend code
Imports PRC.BO
Imports PRC.DTO
Imports DTO
Imports System.Web.Security
Imports System.Data.SqlClient
Imports System.Configuration
Imports DAL.Contacts
Public Class ChangePassword
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("temp") IsNot Nothing Then
If Session("temp") = True Then
lblmsg.Visible = True
lblmsg.ForeColor = Drawing.Color.Red
lblmsg.Text = "First Time login! Please Change your Password"
Session.Remove("temp")
End If
Else
lblmsg.Visible = False
trRowlabel.Visible = False
End If
If Request.QueryString("Name") IsNot Nothing Then
txtUserId.Text = Request.QueryString("Name")
End If
End Sub
Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
litMessage.Text = ""
If txtUserId.Text.Trim.Length = 0 Then
litMessage.Text = litMessage.Text + "<a style=""font-weight: normal; font-size:10pt; color: red"">Please enter a User ID</a>"
txtUserId.Focus()
End If
If txtOldPassword.Text.Trim.Length = 0 Then
litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt; color: red"">Please enter Old Password</a>"
txtOldPassword.Focus()
End If
If txtNewPassword.Text.Trim.Length = 0 Then
litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt; color: red"">Please enter New Password </a>"
txtNewPassword.Focus()
End If
If txtConfirmPassword.Text.Trim.Length = 0 Then
litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt; color: red"">Please Enter Confirm Password</a>"
txtConfirmPassword.Focus()
End If
If Not (txtNewPassword.Text.Trim() = txtConfirmPassword.Text.Trim()) Then
litMessage.Text = litMessage.Text + "</br><a style=""font-weight: normal; font-size:10pt; color: red""> New & Confirm Passwords do not Match</a>"
txtConfirmPassword.Focus()
End If
If Not (litMessage.Text = "") Then
Exit Sub
End If
If String.Equals(txtOldPassword.Text, txtNewPassword.Text) Then
litMessage.Text = "</br><a style=""font-weight: normal; font-size:10pt; color: red"">Old and New Password can't be Same</a>"
Exit Sub
End If
Dim userPwd As New UserPassword
Dim i As Integer = PRC.DTO.PRCContractor.Queries.PRC_AdminChangePassword(txtUserId.Text, userPwd.EncryptPassword(txtOldPassword.Text), userPwd.EncryptPassword(txtNewPassword.Text))
If (i = 1) Then
Dim MyScript As String = "alert('Password Updated Successfully!. Please Login Again!'); window.location = '/Login.aspx';"
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "MyScript", MyScript, True)
ElseIf (i = 3) Then
litMessage.Text = "<a style=""font-weight: normal; font-size:10pt; color: red"">Old Password is Incorrect </a>"
txtOldPassword.Focus()
Else
litMessage.Text = "<a style=""font-weight: normal; font-size:10pt; color: red"">Invalid User id</a>"
txtUserId.Focus()
End If
End Sub
End Class
What I have tried:
getting this error not able to understand why it is coming when the page loads and save button not firing when i clicks it.please help thanks in advance JavaScript runtime error: Unable to get property 'onsubmit' of undefined or null reference code:
@
!%*?&])[A-Za-z\d
@
这篇关于Javascript运行时错误:无法获取未定义或空引用的属性'onsubmit'并保存按钮不会在cliking上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!