Required Field Validator on RadioButton list - asp.net

I have a radiobutton list that the items are dynamically filled. Now, I have a required field validator that works as expected (if I do a postback, it will ask me to select an item in the radiobuttonlist).
When I click on Next, I clear the radiobuttonlist, and dynamically fill it again with the next set of data. But now, the required field validator's message is already there asking me to select an item (without doing a postback).
Any ideas to make the required field validator message only become triggered if I do a postback?
Thanx

You should be able to disable the required field validator client side validation with the following:
ValidatorEnable($("#<%=ReqVal.ClientID%>")[0], false);
Replace the ReqVal with the id of your RequiredFieldValidator that you want to disable.

Related

ASP.NET validation controls

I have a situation where I have a form that has some validation controls for required fields. They fire just fine if the user does not have the required fields.
The thing is I also have a menu above the form which allows the user to select another location which is then reflected on the form.
This is where I run into an issue...
If the user already selected a location and then wishes to change to a different location, the form does not allow for this as required fields have not been entered.
I was wondering if there is a way to tell the validation controls not to fire in these situation.
My other option would be to do a validation on click of the submit button in which case I would not be able to take advantage of the ASP.NET required validation control.
Basically I want the validation to occur for the required fields only if the submit button is clicked.
Look at CausesValidation and ValidationGroup properties. I think they will help you to solve your problem
On the menu item set CausesValidation to false.
You can also use validation groups and set the validationgroup property of the validator and the submit button to the same value.

How to force an user to save?

I have the following situation:
I coded a aspx app c#, the user has 4 dropdownlists, one textbox and two buttons (cancel, save) in a page. I need the user to be remembered to save any changes to the textbox before allowing him to change the index of any dropdownlist. So, if the user changes the textbox value, he only have the option to cancel or save those chhanges. If he tries to do something else, like changing the index of a dropdownlist, I need to cancel this event and give him a message to save or cancel before do this.
I've tried many ways, but they all seem amatours to me and give lots of colateral efects. Is there any decent/elegant way to do this?
Create a custom validator for the TextBox. In the DropDownList's SelectedIndexChanged event handlers check the status of the TextBox and set the validator's args.IsValid property appropriately - you can notify the user via the TextBox CustomValidator ErrorMessage property to click Save if the value of the TextBox has changed.

Validation is not working

I have one asp content page.Its contain many controls like dropdownlist,textbox etc.All controls are inside a div tag.I gave required field validator for all my drop down list.i have one SAVE button that reside inside another div tag.I gave SAVE button cause validation true.But my problem is that, the validator is not working and the page.Isvalid property is true.What is the problem with my code?
Please make sure you have set the ControlToValidate property to the DropDownList id. Also you need to set the InitialValue property on the RequiredFieldValidator when validating a DropDownList. This basically just tells the Validator which item is the intial value (which will throw a validation error when it is selected).
Hope this helps,
Neil

How to disable listbox's click event

I have a listbox which acts as a list of items. If you click on some item, it's contents are shown in the panel on the right (few textboxes etc.).
I need to have a validation on these controls as all of them are required fields. And I do have it. The problem is that, even when the validators are not valid, user can click the listbox and change active index (that doesn't have impact on the panel on the right, as SelectedIndexChanged isn't fired).
The validators are standard RequiredFieldValidator with their Display property set to "Dynamic". So, what I want is to disallow the user clicking on the listbox and changing the index untill all validators are Valid.
What would be your solution for that? Is that even possible?
Did you try setting ListBox.Enabled = false when you actually do fire off the SelectedIndexChanged, and reenabling when your required fields meet the Page.IsValid requirement to proceed in code execution?

How can I make a custom validator fire even if a textbox is empty?

I set a custom validator on a textbox.
It only validates if there is some text in the textbox, I need it to fire all the time when someone clicks on the submit button.
How can I do this?
Set your CustomValidator.ValidateEmptyText to true.
From MSDN:
[ValidateEmptyText] [g]ets or sets a Boolean value indicating whether empty text should be validated.

Resources