Avatar of RadhaKrishnaKiJaya
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!
ASP.NET.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
RadhaKrishnaKiJaya

8/22/2022 - Mon
sammySeltzer

Since no code, I fashion a guess.

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?

<meta http-equiv="X-UA-Compatible" content="IE=7, IE=8, IE=9, IE=10, IE=11" />

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.
RadhaKrishnaKiJaya

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-Compatible" content="IE=7, IE=8, IE=9, IE=10, IE=11" />

Thank you!
sammySeltzer

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?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
RadhaKrishnaKiJaya

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.options.selectedIndex == 0)
                        arguments.IsValid = false;
                  else
                        arguments.IsValid = true;
                        
            }

            </script>
       </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">
                                          <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>&nbsp;&nbsp;
                        </tr>
                        <tr>
                              <td style="HEIGHT: 18px" colSpan="3"><asp:customvalidator id="Customvalidator3" runat="server" ControlToValidate="ddlMonth" ErrorMessage="Selected Month is not a valid selection "
                        ClientValidationFunction="ValidateMonth"></asp:customvalidator><br />

                        </tr>

            </form>
      </body>
</HTML>
sammySeltzer

Sorry for the late response.

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>&nbsp;&nbsp;
                                     <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> 

Open in new window

RadhaKrishnaKiJaya

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!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
sammySeltzer

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
RadhaKrishnaKiJaya

ASKER
Thank you sammySeltzer.