I had ddl and I added compare validator to make user choose from DDl.And I set all it,s properties well but when i forget to select ddl the validator apear well but when I selected from ddl The astrics(*) as error text it was still apear although I added it,s property focus on error=true.So please any one help me.
*
You should probably try to use another validator. It sounds like using the CustomValidator instead of the CompareValidator would be your way to go.
The asterix means that one of your validators says that your page is not valid. Try to set a breakpoint and determine which validator is not valid.
Related
I have a new validator added to one screen to validate a text box. If user clicks on submit button, the validation summary will pop up but not showing the text of this validator. It works well with all other validators on this page.
In other words, this validator works but is not shown in the validation summary.
Check if you use the same name as the default validation group may not verification. I suggest you to check out her hard have added value.
I figured it out, I used the Text property of the validator instead of ErrorMessage property. Thanks for your comment #MichaelLiu which made me look at the code.
i have two check boxes with male/female and i would like to add a required field validator for them so if none is checked then a custom error appears, i can already do this but with one control not two.
thanks
All I needed to do was instead of adding two separate CheckBoxs ,I needed to add a CheckBoxList:
CheckBoxList
and then use a normal RequiredFieldValidator on the CheckBoxList:
RequiredFieldValidator
You'll need to use the CustomValidator with a ClientValidationFunction
http://forums.asp.net/t/1402179.aspx
or -
You'll need to write a custom control or use one that's already made:
-http://www.codeproject.com/KB/validation/MultiDependValidator.aspx
I have GridView and one columns is a RadioButton for select. How can I set a validator for columns to check that at least one RadioButton is selected?
I posted to a similar question the other day with a solution that should work for you:
How to check that at least one RadioButtonList has an item selected?
It uses a CustomValidator with a server side check to ensure at least one item is selected. You will need to substitute looking for a RadioButton instead of the RadioButtonList and maybe a few other tweeks but the code should work for what you need. It searchs for all of one type of control and checks for a specific critera. In your case look for all RadioButton controls and ensure at least one is checked.
there is no out-of-the-box way for what you are asking, you will need to use custom validator and implement the logic yourself on the client as well as on the server side; few way you can go about it, the one that comes to mind is to have the custom validator logic check at least one of the checkboxes is checked for passing IsValid, we will need more details about your structure to provide more specific solution
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
I have a form that I need the user to be able to type something in a textbox, after they tab out have them enter the same value in another textbox in proximity to it to assure they entered it incorrectly. After that, the second textbox is to disappear and they will continue to the next field without ever having a postback.
Does anyone have any recommendations on how to do this most efficiently? Is there a control that will facilitate this for me?
You can do it by javascript easily. on the onblur or onchange clientside events you should check two textbox's values.
An alternative option : maybe you want to use CompareValidator to compare values of your form elements. Don't forget to set EnableClientScript=true and use ValidationSummary control.