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 6709683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:54:39+00:00 2026-05-26T07:54:39+00:00

I have a problem that is making me crazy. On my page I have

  • 0

I have a problem that is making me crazy. On my page I have one Javascript validation and two ASP.NET validators. The validation outcome depends just on the result of the Javascript. That means if the Javascript returns true the ASP.NET validators are not checked.

The Javascript code is:

<script type="text/javascript">

    function Validate() {
        var ddlObj = document.getElementById('<%=ddStatus.ClientID%>');
        var txtObj = document.getElementById('<%=txtComment.ClientID%>');
        if (ddlObj.selectedIndex != 0) {
            if (txtObj.value == "") {
                alert("Any change of Status requires a comment!");
                txtObj.focus();
                return false;
            }
        }
    }
</script>

Instead the two ASP.NET validators are:

<td><asp:TextBox runat="server" ID="txtSerialNr" ></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="txtSerialNr" ErrorMessage="***" />
                        </td>

<td><asp:TextBox runat="server" ID="txtProdName" ></asp:TextBox>
<asp:RequiredFieldValidator runat="server" ID="rfv1" ControlToValidate="txtProdName" ErrorMessage="***"></asp:RequiredFieldValidator></td>

Anybody might help? Thanks

UPDATE:

I call the Javascript from a button:

    <asp:Button runat="server" ID="btnSubmit" Text="Save New Product" 
style="cursor:hand" OnClick="btnSubmit_Click" />

But I register the attribute from the code-behind:

protected void Page_Load(object sender, EventArgs e)
{
    btnSubmit.Attributes.Add("OnClientClick", "return Validate()");
}
  • 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-26T07:54:40+00:00Added an answer on May 26, 2026 at 7:54 am

    You can fire the client side validation from within the Validate() function:

    validate = function(){
        bool isValid = Page_ClientValidate(""); //triggers validation
        if (isValid){
            var ddlObj = document.getElementById("<%=ddStatus.ClientID%>"); 
            var txtObj = document.getElementById("<%=txtComment.ClientID%>"); 
            if (ddlObj.selectedIndex != 0) { 
                if (txtObj.value == "") { 
                    alert("Any change of Status requires a comment!"); 
                    txtObj.focus(); 
                    isValid = false; 
                } 
            } 
        }
        return isValid;
    }
    

    Markup:

    <asp:Button runat="server" OnClientClick="return validate();" ... />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem is making me crazy. Actually I have multiple problems. First one: Why
I have a new problem that bugs me ... I am making a web
I have a problem on a program I'm making that I honestly can't find
I've got this simple problem that is really making me crazy. I've got a
I have a problem that is surely familiar to many: I'm making a call
I'm dealing with a problem that is really making me crazy. I've got a
I'm facing a problem that is making my head explode. Basically I have a
In a couple of scripts that I use I have problem that is intermittent.
(I have a problem that I illustrated in this question but had no correct
I have a problem that output string must be utf8-formatted, I am writing currently

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.