RadhaKrishnaKiJaya
asked on
Custom Validator not working
Hello Experts,
My CustomValidator is not working in my local machine. But when deployed in Windows Server 2008 machine, it is working. Any idea why it is behaving like this? Below is the environment I am using. Thank you in advance.
OS: Windows 7
Visual Studio: 2010
Server: Windows 2008 R2
Thank You!
My CustomValidator is not working in my local machine. But when deployed in Windows Server 2008 machine, it is working. Any idea why it is behaving like this? Below is the environment I am using. Thank you in advance.
OS: Windows 7
Visual Studio: 2010
Server: Windows 2008 R2
Thank You!
ASKER
Hi sammySeltzer,
Thank you for your help. I am using IE 11. I am not using jQuery. Just using ASP.NET inbuilt validator with JavaScript. Please explain more, how the F12 key works? Also, what does the following line will do?
<meta http-equiv="X-UA-Compatibl e" content="IE=7, IE=8, IE=9, IE=10, IE=11" />
Thank you!
Thank you for your help. I am using IE 11. I am not using jQuery. Just using ASP.NET inbuilt validator with JavaScript. Please explain more, how the F12 key works? Also, what does the following line will do?
<meta http-equiv="X-UA-Compatibl
Thank you!
I suggested using F12 because I assumed you were using some javascript. That helps with debugging.
The meta tag is intended to make those browsers listed compatible, again, assume some jquery is being used.
can you show your code, just the customValidator bit?
The meta tag is intended to make those browsers listed compatible, again, assume some jquery is being used.
can you show your code, just the customValidator bit?
ASKER
If I copy this code to a different program and try to run, it works just fine.
<HTML>
<HEAD>
<title>Credit Card Check</title>
<script language="javascript">
function ValidateMonth(source, arguments)
{
if(window.Form1.ddlMonth.o ptions.sel ectedIndex == 0)
arguments.IsValid = false;
else
arguments.IsValid = true;
}
</script>
</HEAD>
<body bgColor="#a7a7db" MS_POSITIONING="GridLayout ">
<form id="Form1" onsubmit="javascript:Valid ateMe();" method="post" runat="server">
<table style="WIDTH: 592px" cellSpacing="0" cellPadding="0" border="0">
<tr>
<td style="WIDTH: 305px; HEIGHT: 5px">Expiration Month:</td>
<td class="style3"><asp:dropdo wnlist id="ddlMonth" runat="server" Width="112px">
<asp:ListItem Value="Select Month">Select Month</asp:ListItem>
<asp:ListItem Value="01">Jan</asp:ListIt em>
<asp:ListItem Value="02">Feb</asp:ListIt em>
<asp:ListItem Value="03">Mar</asp:ListIt em>
<asp:ListItem Value="04">Apr</asp:ListIt em>
<asp:ListItem Value="05">May</asp:ListIt em>
<asp:ListItem Value="06">Jun</asp:ListIt em>
<asp:ListItem Value="07">Jul</asp:ListIt em>
<asp:ListItem Value="08">Aug</asp:ListIt em>
<asp:ListItem Value="09">Sep</asp:ListIt em>
<asp:ListItem Value="10">Oct</asp:ListIt em>
<asp:ListItem Value="11">Nov</asp:ListIt em>
<asp:ListItem Value="12">Dec</asp:ListIt em>
</asp:dropdownlist> & nbsp;
</tr>
<tr>
<td style="HEIGHT: 18px" colSpan="3"><asp:customval idator id="Customvalidator3" runat="server" ControlToValidate="ddlMont h" ErrorMessage="Selected Month is not a valid selection "
ClientValidationFunction=" ValidateMo nth"></asp :customval idator><br />
</tr>
</form>
</body>
</HTML>
<HTML>
<HEAD>
<title>Credit Card Check</title>
<script language="javascript">
function ValidateMonth(source, arguments)
{
if(window.Form1.ddlMonth.o
arguments.IsValid = false;
else
arguments.IsValid = true;
}
</script>
</HEAD>
<body bgColor="#a7a7db" MS_POSITIONING="GridLayout
<form id="Form1" onsubmit="javascript:Valid
<table style="WIDTH: 592px" cellSpacing="0" cellPadding="0" border="0">
<tr>
<td style="WIDTH: 305px; HEIGHT: 5px">Expiration Month:</td>
<td class="style3"><asp:dropdo
<asp:ListItem Value="Select Month">Select Month</asp:ListItem>
<asp:ListItem Value="01">Jan</asp:ListIt
<asp:ListItem Value="02">Feb</asp:ListIt
<asp:ListItem Value="03">Mar</asp:ListIt
<asp:ListItem Value="04">Apr</asp:ListIt
<asp:ListItem Value="05">May</asp:ListIt
<asp:ListItem Value="06">Jun</asp:ListIt
<asp:ListItem Value="07">Jul</asp:ListIt
<asp:ListItem Value="08">Aug</asp:ListIt
<asp:ListItem Value="09">Sep</asp:ListIt
<asp:ListItem Value="10">Oct</asp:ListIt
<asp:ListItem Value="11">Nov</asp:ListIt
<asp:ListItem Value="12">Dec</asp:ListIt
</asp:dropdownlist> &
</tr>
<tr>
<td style="HEIGHT: 18px" colSpan="3"><asp:customval
ClientValidationFunction="
</tr>
</form>
</body>
</HTML>
Sorry for the late response.
If all you are doing is just validating the dropdownlist, why not make it simple and easy?
Something like:
If all you are doing is just validating the dropdownlist, why not make it simple and easy?
Something like:
<HEAD>
<title>Credit Card Check</title>
</HEAD>
<body bgColor="#a7a7db" MS_POSITIONING="GridLayout">
<form id="Form1" onsubmit="javascript:ValidateMe();" method="post" runat="server">
<table style="WIDTH: 592px" cellSpacing="0" cellPadding="0" border="0">
<tr>
<td style="WIDTH: 305px; HEIGHT: 5px">Expiration Month:</td>
<td class="style3"><asp:dropdownlist id="ddlMonth" runat="server" Width="112px" AppendDataBoundItems="True">
<asp:ListItem Value="Select Month">Select Month</asp:ListItem>
<asp:ListItem Value="01">Jan</asp:ListItem>
<asp:ListItem Value="02">Feb</asp:ListItem>
<asp:ListItem Value="03">Mar</asp:ListItem>
<asp:ListItem Value="04">Apr</asp:ListItem>
<asp:ListItem Value="05">May</asp:ListItem>
<asp:ListItem Value="06">Jun</asp:ListItem>
<asp:ListItem Value="07">Jul</asp:ListItem>
<asp:ListItem Value="08">Aug</asp:ListItem>
<asp:ListItem Value="09">Sep</asp:ListItem>
<asp:ListItem Value="10">Oct</asp:ListItem>
<asp:ListItem Value="11">Nov</asp:ListItem>
<asp:ListItem Value="12">Dec</asp:ListItem>
</asp:dropdownlist>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlMonth"
ErrorMessage="Selected Month is not a valid selection" InitialValue="Select Month"></asp:RequiredFieldValidator>
</td>
</tr>
</form>
</body>
</HTML>
ASKER
Thank you sammySeltzer,
The reason I am not using that is, I have Year to select from the dropdown too and I need to use the CustomValidator to validate Year must be >= Current Year, which RequiredFieldValidator cannot validate this.
The problem is this is not a new code. This has been running for years together. I don't know what happened, this stopped working.
Thank you!
The reason I am not using that is, I have Year to select from the dropdown too and I need to use the CustomValidator to validate Year must be >= Current Year, which RequiredFieldValidator cannot validate this.
The problem is this is not a new code. This has been running for years together. I don't know what happened, this stopped working.
Thank you!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you sammySeltzer.
What browser are you using?
I suspect you are using jquery?
What if you add this line to the top of your page between <head>...</head> section?
Open in new window
You can also hit the f12 key if using IE or firebug if using firefox to get better idea of what is going on.
If all else fails, you can show some code.