简体   繁体   中英

How can I make a RequiredFieldValidator trigger a message elsewhere on the page?

I have a page with a repeater containing RadioButtonLists which have requiredFieldValidators attached to them. I need to keep the RFV next to the control (it's the only way I can get it to work to be honest!)

However, the form is made up of a few sections contained in an accordion. This means that when the form is submitted, the item that has failed validation may not be visible, so the user won't know where the error is.

Is there a way I can also have a message by the submit button which is triggered by an RFV changing saying "please go back and check your answers" or something? I guess I'd need to use JQuery / JavaScript as it would be clientside.

Try "ValidationSummary". look for example from here.

http://www.w3schools.com/aspnet/control_validationsummary.asp

There is a special ValidationSummary control for that:

<asp:ValidationSummary ID="Summary" runat="server"
    DisplayMode="SingleParagraph"
    HeaderText="Please go back and check your answers" />

This control is used to summarize all validation errors on the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM