?
Solved

How do I force validation on an asp .net page from the client side (javascript/jquery)?

Posted on 2010-08-24
1
Medium Priority
?
708 Views
Last Modified: 2013-11-27
Hi:

I would like to be able force validation to fire from my asp .net page.
Basically, I catch the onChange() in a total amount field.
From that point, I'd like to force the ALL individual amount fields' validators to fire.
The individual amounts are contained in a custom user (ascx) control that's embedded in a repeater control.



I know how force validation on a single validator, I'd like to figure out to force it to fire on all the validators
embedded in the repeater control.



My asp .net page looks more or less like this:


===============================================================
This is what my asp:repeater control looks like:
===============================================================
<div id="div1">
    <asp:Repeater ID="Repeater1" runat="server"  >
        <HeaderTemplate>
            <table border="1" width="800px">
                <tr>
                    <td>
                        <strong> Repeater Header</strong>
                    </td>
                </tr>
        </HeaderTemplate>

        <ItemTemplate>
            <tr>
                <td class="indent vmid">
                    <uc1:CustomUserControl ID="CustomUserControl1" runat="server"                
                        Index ='<%# DataBinder.Eval(Container, "ItemIndex") %>'
                        FullName='<%# DataBinder.Eval(Container.DataItem, "FullName") %>'
                    />
                </td>
            </tr>
        </ItemTemplate>
   
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
</div>


===============================================================
This is what a snippet of my custom user control looks like (ascx)
===============================================================

<asp:Label ID="lTravelerTourCenterID" Width="10" runat="server" Visible="false"/>
<asp:Label ID="lFullName" Width="170" runat="server" />
<asp:TextBox ID="tAmount" Width="170" runat="server" />

<asp:RegularExpressionValidator ControlToValidate="tAmount"                         
      ValidationExpression="^[0-9]+(,[0-9]{3})*(\.[0-9]{0,2})*"
    ErrorMessage="Enter a valid amount" runat="server" ID="reValidator" Display="Dynamic" CssClass="error small" />

<asp:CustomValidator ID="cvtIndividualAmountPaxPayment" runat="server" ControlToValidate="tAmount"
      ClientValidationFunction="validatePaxPayments"
    ForeColor=" " CssClass="error small" ErrorMessage="Total pax payments exceed GL's account." Display="Dynamic"/>

<asp:CustomValidator ID="cvtIndividualAmountMinDeposit" runat="server" ControlToValidate="tAmount"  
      ClientValidationFunction="validatePaxMinDeposit" OnServerValidate="OnValidateMinPaxPayment"
    ForeColor=" " CssClass="error small" ErrorMessage="Payment cannot be less than minimal deposit." Display="Dynamic"/>

<asp:CustomValidator ID="cvtIndividualAmount" runat="server" ControlToValidate="tAmount"
      ClientValidationFunction="validateIndividualAmount" OnServerValidate="OnValidateIndividualAmount"
    ForeColor=" " CssClass="error small" ErrorMessage="Enter a valid payment amount" Display="Dynamic"/>

<div class="rowPayment smaller mrgl30" id="PaymentInfoType" runat="server" visible="false">
     <div class="columnA" id="divCheck" runat="server" >
         <exp:Check ID="checkPayment" runat="server" />
     </div>
</div>



Thanks,
JohnB
0
Comment
Question by:jxbma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Fareed Ali Khan earned 2000 total points
ID: 33518423
Hi,

Please assign the validationGroup to controls and CustomValidators, lets suppose 2 textboxes and their CustomValidators have the ValidationGroup "ABC" and the button is also have the same validationGroup "ABC" then whenever button will submit it will verify all the validators who have group "ABC".

for reference please read the following article:

http://www.dotnet-guide.com/validationgroups.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question