Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6760641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:05:17+00:00 2026-05-26T14:05:17+00:00

I am trying to validate a textbox based on a dropdownlist, e.g. if ddl

  • 0

I am trying to validate a textbox based on a dropdownlist, e.g. if ddl value is ‘Day’, textbox value cannot exceed 31. It seems that no matter what I enter triggers my custom validator error, what am I doing wrong, thanks:

            <asp:TextBox ID="uitxtCamLastVisitDur" runat="server" CssClass="tooltip" 
                         Width="65px" Enabled="False" ToolTip="Indicates a required spending on the member's last visit."></asp:TextBox> 
            <asp:CustomValidator ID="ccvLastVisitDuration" runat="server" 
                ClientValidationFunction="validateDurationType" 
                ControlToValidate="uitxtCamLastVisitDur"
                ErrorMessage="Duration input error"></asp:CustomValidator>

function validateDurationType(src, args) {

    if (document.getElementById('<%= uiddlCamLastVisitDurType.ClientID%>').selectedIndex == 1)
        if (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value < 0) || (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value > 31))) {
            args.IsValid = false;
            return;
     }
     if (document.getElementById('<%= uiddlCamLastVisitDurType.ClientID%>').selectedIndex == 2)
        if (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value < 0) || (parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value > 12))) {
            args.IsValid = false;
            return;
     }  
  args.IsValid = true;
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:05:18+00:00Added an answer on May 26, 2026 at 2:05 pm

    You have javascript errors on your function. You are missing parenthesis on parseInt:

    parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value < 0)
    

    Should be

    parseInt(document.getElementById('<%= uitxtCamLastVisitDur.ClientID%>').value) < 0)
    

    All of them have the same issue, by the way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to validate a field based on another field's value. <h:form id=item>
I am trying to validate a textbox to enter only numbers and set maximum
I'm trying to create a method that will custom validate any TextBox control passed
I am trying to validate that either of 2 textbox fields in my view
I'm trying to validate an ASP TextBox that can only have 1-2 digits (not
I'm trying to validate that a submitted URL doesn't already exist in the database.
I am trying to validate textbox values during runtime in vb.net I have following
I'm trying to validate a UI change when Enter key is pressed. The UI
I have a problem with a master page containing a asp:textbox that I'm trying
I am currently trying to validate a textbox, so only letters (a-Z) can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.