I am using an ajax tab control. I am using a combination of required field validators and custom validators. I am using a validation summary at the end of the page. My problem is when there is a validation error on different tabs I get an IE error because it cannot set focus on all of the fields at once because they are on different tabs. I know if I set focus on error to false the error does not occur. Is there any other way around this?
Set the ValidationGroup of groups.. for more info click
Related
I have some input fields, regular expression validators, and custom validators inside an ASP.NET ASCX control. The behavior is a bit odd in that it works the following way:
If a client side validator flags an error message and I tab away from the input field and click submit then the page posts as it should. However, if a client side validator has flagged an error and instead I correct the error and click submit button then the error is cleared but the page is not submitted until I click the submit button a second time.
My question is how do I change this behavior such that I only need to click the submit button once to both clear the error and postback the page? Also, is this "behavior" standard?
Update: This behavior occurs without using the user control. I believe it is specific behavior to the CompareValidator. Nope, same behavior occurs with custom validator. If I don't "tab away" and click the button then I must click it twice to get the postback to occur. The first click just clears the validators.
The issue is that the CustomValidator has display type as Dynamic and not Static. This post helped me to discover the answer
RequiredFieldValidator have to click twice
I will give credit for anyone who explains why it causes this behavior.
In one of our projects we want to show the "Required field validation error" by changing the border color of the corresponding textbox. our page contains a lot of required field validator,regular expression validator etc. But we want to highlight only the required field errors.
Is there any way to do this without using any custom validation function.?
or Is there any method to find all the required field validators in a page in the client side. If we can find this i think we can highlight the corresponding error textbox
one option, maybe less annoying than switching to custom validators, is to create your own javascript validation function that is triggered with a submit click. from here you can change the appearance of the invalid fields.
I have a RegularExpressionValidator for a TextBox in a control, which itself is part of another control. When I click the button to submit the form, it seems that it should not do so unless all child controls are properly validated. However, what ends up happening is that I see the validation error message pop up for each control that failed to validate before the page posts back anyway and fails when it can't parse the malformed input.
I have tried surrounding the failing code with if (Page.IsValid) {...} to make sure it doesn't run without complete validation, but the property ends up being true by the time I hit the breakpoint.
Shouldn't an entire page be invalid if any child controls are not successfully validated?
Do you have different ValidationGroup controls defined? As long as the validators in the same validation group as the button are all setup correctly, yes it should block. Unless, for some reason, the JS is failing to load for the validators.
HTH.
Set "CausesValidation = true " to your submit button, I guess your problem will be solved.
Have you called Page.Validate() before using Page.IsValid ?
Why are my errors showing up beside my control and in the validation control summary?
By default if you have a ValidationSummary control, the error message shows in both places. If you want the error message to only show in the ValidationSummary, then set the Display property in your validation control to None.
From the BaseValidator.Display Property:
None The validation message is never displayed inline.
Static Space for the validation message is allocated in the page layout.
Dynamic Space for the validation message is dynamically added to the page if validation fails.
Most likely because you did not set
Display="None"
in your validation control. By setting Display to None you are indicating that you do not want the error message to appear in the place of the validation control itself, only in the validation summary.
I have a little problem with the validation in one form
the form is composed by two taqs. There is a "Save" button in each tap (is the same control for both) and saves the form info. there are validation controls in one tab but not in the second. When we try to save the info from the second tab, and the info has not been filled in the first tab, the validators fire, and nothing happends, but because this validators are shown in the other tab, the end user might be thinking that the operation has been completed, instead, I would like to show a msgBox telling the user about the errors in the other tab. How do I know that the validators in the other tab have been fired, and display the error message when the button is clicked?
You should use the ValidationGroup of your validator controls and the appropriate submit button. You can also use a ValidationSummary control which displays a summary of the validation messages - this can be set to display a message box if you want by setting the property ShowMessageBox=true.
taqs - tap
dear why are you so confused?
All the validators are posted to the page as JavaScript functions. You can call the validation function on button's click and take the appropriate action.
You can use on buttons
onClientClick="Page_ClientValidate();"