In Function when i use .checked then it stop working & generate below Error. Currently im using Visual Studio 2015.Please Help
function GenderValidation(sender , e)
{
var male = document.getElementById('RadioButton_male').Checked;
var female = document.getElementById('RadioButton_female').Checked;
if (male == true || female == true)
{
e.IsValid = true;
} else {
e.IsValid = false;
}
}
**
**
This is my Complete code
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="contactus.aspx.cs" Inherits="DVManagmentProject.contactus" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.auto-style1 {
width: 70%;
}
.auto-style2 {
width: 190px;
}
.auto-style3 {
width: 190px;
height: 34px;
}
.auto-style4 {
height: 34px;
}
.auto-style5 {
width: 190px;
height: 150px;
}
.auto-style6 {
height: 150px;
}
</style>
<script type="text/javascript" >
function GenderValidation(sender , e)
{
var male = document.getElementById('ContentPlaceHolder1_RadioButton_male').Checked;
var female = document.getElementById('ContentPlaceHolder1_RadioButton_female').Checked;
if (male == true || female == true)
{
e.IsValid = true;
} else {
e.IsValid = false;
}
}
function CustomValidatorAgremennt(sender, e)
{
var agreemenT = document.getElementById('ContentPlaceHolder1_CheckBox_agreement').Checked;
if(agreemenT==true)
{
e.IsValid = true;
}else
{
e.IsValid = false;
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2>
This is Contact Us Page</h2>
<asp:ValidationSummary ID="contact_ValidationSummary" runat="server" BackColor="#FFFF99" ForeColor="Black" Font-Bold="true" Width="694px" BorderStyle="Double" />
<h3> Please Fill the Form Below:</h3>
<br />
<table class="auto-style1">
<tr>
<td class="auto-style2">Name:</td>
<td>
<asp:TextBox ID="name_TextBox" runat="server" Width="320px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_name"
runat="server" Text="*"
ErrorMessage="Please Enter Your Name"
ForeColor="Red"
ControlToValidate="name_TextBox"
Display="Dynamic"
> </asp:RequiredFieldValidator>
<%-- <asp:RangeValidator ID="RangeValidator_name" runat="server"
ErrorMessage="*Text should between 10 to 30" MinimumValue="10" MaximumValue="30"
Type="Integer" ControlToValidate="name_TextBox"
Display="Dynamic"></asp:RangeValidator>--%>
</td>
</tr>
<tr>
<td class="auto-style3">Email:</td>
<td class="auto-style4">
<asp:TextBox ID="email_TextBox" runat="server" Width="320px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_email"
runat="server"
SetFocusOnError="true"
Text="*"
ErrorMessage="Please Enter Your Email Name"
ControlToValidate="email_TextBox"
ForeColor="Red"
Display="Dynamic"> </asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator_email_TextBox"
runat="server"
ErrorMessage="Please Enter Correct Email Format"
Display="Dynamic"
ControlToValidate="email_TextBox"
ForeColor="Red"
SetFocusOnError="true"
Text="*"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" > </asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Re-Enter Email:</td>
<td class="auto-style4">
<asp:TextBox ID="TextBox_ReEmail" runat="server" Width="320px"></asp:TextBox>
<asp:CompareValidator
ID="CompareValidator_ReEmail_TextBox"
runat="server"
ErrorMessage="Email Must be Match"
Operator="Equal"
ControlToValidate="TextBox_ReEmail"
ControlToCompare="email_TextBox"
Type="String"
Display="Dynamic"
ForeColor="Red"
Font-Bold="true">*</asp:CompareValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator_ReEmail"
runat="server"
SetFocusOnError="true"
Text="*"
ErrorMessage="Please Confirm Your Email Name"
ControlToValidate="TextBox_ReEmail"
ForeColor="Red"
Display="Dynamic"> </asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator_ReEmail"
runat="server"
ErrorMessage="Please Enter Correct Re-Email Format"
Display="Dynamic"
ControlToValidate="TextBox_ReEmail"
ForeColor="Red"
SetFocusOnError="true"
Text="*"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Gender:</td>
<td class="auto-style4">
<asp:RadioButton ID="RadioButton_male" runat="server" Text="Male" GroupName="GenderGroup" />
<asp:RadioButton ID="RadioButton_female" runat="server" Text="Female" GroupName="GenderGroup" />
<asp:CustomValidator
ID="CustomValidator_genders"
runat="server"
ErrorMessage="Please Select Gender.!"
Font-Bold="True"
Display="Dynamic" ForeColor="Red" OnServerValidate="CustomValidator_genders_ServerValidate">*</asp:CustomValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Age:</td>
<td class="auto-style4">
<asp:TextBox ID="Age_TextBox" runat="server" Width="318px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server"
SetFocusOnError="true"
Text="*"
ErrorMessage="Please Enter Your Age"
ControlToValidate="Age_TextBox"
ForeColor="Red"
Display="Dynamic"> </asp:RequiredFieldValidator>
<asp:RangeValidator
ID="RangeValidator_Age"
runat="server"
ErrorMessage="Age should between 18 to 99"
Type="Integer"
Display="Dynamic"
SetFocusOnError="true"
ControlToValidate="Age_TextBox"
MinimumValue="18"
MaximumValue="99"
></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Subject:</td>
<td>
<asp:DropDownList ID="subject_DropDownList" runat="server" Width="320px">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="auto-style5">Message </td>
<td class="auto-style6">
<asp:TextBox ID="message_TextBox" runat="server" Height="140px" TextMode="MultiLine" Width="320px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style2">Agreement:</td>
<td>
<asp:CheckBox ID="CheckBox_agreement" runat="server" Text="Please Select Our Terms And Conditions.!" />
<asp:CustomValidator
ID="CustomValidator_Agreement"
runat="server"
Display="Dynamic"
ErrorMessage="Please Check Terms and Conditions"
Font-Bold="True"
ForeColor="Red" OnServerValidate="CustomValidator_Agreement_ServerValidate">*</asp:CustomValidator>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td>
<asp:Button ID="submit_Button" runat="server" Font-Bold="True" Text="Submit" Width="320px" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
<p>
</p>
</asp:Content>
This is Debbuger Code
[1]: https://i.stack.imgur.com/PG8hC.jpg
[2]: https://i.stack.imgur.com/Jqw0X.jpg
[3]: https://i.stack.imgur.com/DuaNT.jpg
[4]: https://i.stack.imgur.com/DrTPP.jpg
[5]: https://i.stack.imgur.com/1Dhc1.jpg
[6]: https://i.stack.imgur.com/880dI.jpg
[7]: https://i.stack.imgur.com/DWQ7D.jpg
[8]: https://i.stack.imgur.com/LdHXg.jpg
[9]: https://i.stack.imgur.com/xVXI1.jpg
[10]: https://i.stack.imgur.com/qC4LA.jpg
Problem is Solved . I have Changed
ContentPlaceHolder1_RadioButton_male and ContentPlaceHolder1_RadioButton_female
instead of
RadioButton_male and RadioButton_female
as well as in Javascript Function .i have changed (.Checked) in small (.checked) and it worked for me .
User contributions licensed under CC BY-SA 3.0