TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
harshit verma
NA
36
2.5k
Javascript Issue
Aug 17 2018 1:12 AM
Hi
I have a javascript in which I am trying to validate data and display error message in a label but the label is not displaying the error message. Below is my code.
Kindly help me with this issue.
<%@ Page Language=
"C#"
AutoEventWireup=
"true"
CodeBehind=
"KUD.aspx.cs"
Inherits=
"Javascript_Testing.KUD"
%>
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title></title>
<script type=
"text/javascript"
language=
"javascript"
>
function
ValidateForm() {
debugger
;
var
result =
true
;
if
(document.getElementById(
"<%=txtFName.ClientID%>"
).innerText ==
""
) {
document.getElementById(
"<%=errFName.ClientID%>"
).innerHTML =
"First Name is required!"
;
}
}
</script>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<div>
<table border=
"1"
style=
"border-style: solid"
>
<tr>
<td>
<asp:Label ID=
"lblFName"
runat=
"server"
>First Name</asp:Label></td>
<td>
<asp:TextBox ID=
"txtFName"
runat=
"server"
></asp:TextBox></td>
<td>
<asp:Label ID=
"errFName"
runat=
"server"
></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID=
"lblLName"
runat=
"server"
>Last Name</asp:Label></td>
<td>
<asp:TextBox ID=
"txtLName"
runat=
"server"
></asp:TextBox></td>
<td>
<asp:Label ID=
"errLName"
runat=
"server"
></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID=
"lblEmail"
runat=
"server"
>E-Mail</asp:Label></td>
<td>
<asp:TextBox ID=
"txtEmail"
runat=
"server"
></asp:TextBox></td>
<td>
<asp:Label ID=
"errEmail"
runat=
"server"
></asp:Label></td>
</tr>
<tr>
<td>
<asp:Button ID=
"btnSubmit"
runat=
"server"
Text=
"Submit"
OnClick=
"btnSubmit_Click"
OnClientClick=
"ValidateForm()"
/>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Thanks
Reply
Answers (
9
)
Upload Word File and read the fields
Plzz Solve In this code error