ValidatorEnable not working

I am trying to use the ValidatorEnable() on a page.
As I debug, the code calls the Javascript with the Validators. I can even see that the Validators get enabled after the javascript function runs.

But then no validation message shows on the page for the validations.
If I enable the same Validators thru backend code, they work as needed. But I need to do this on the page when controls are changed, so I need client side ValidatorEnable().

What am I missing?
ArikkanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MlandaTCommented:
It might help if you posted a sample of what your validator code looks like. I take it you are using CustomValidators. Are you setting args.IsValid? Do you have a ValidationSummary on the page? Are you using ValidationGroups? What happens if you try to manually call Page_ClientValidate() on the client side (or Page_ClientValidate('groupname') is using ValidationGroups)?
0
ArikkanAuthor Commented:
UI END
<asp:TextBox ID="txtStreetName" runat="server" CssClass="Size" MaxLength="50"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvStreetName" runat="server"                                     ControlToValidate="txtStreetName" Display="None" ErrorMessage="Street cannot be null"
ValidationGroup = "AddressInformation"></asp:RequiredFieldValidator>  


Backend

            Dim residentialAddressValidatorsCheck As String = "ResidentialAddressValidatorsCheck('"
                                                                                                         Me.rfvHouse.ClientID() & "','" & _
                                                                                                         Me.rfvStreetName.ClientID() & "','" & _
                                                                                                         Me.rfvAddress.ClientID() & "','" & _
                                                                                                         Me.rfvtxtResidentialCity.ClientID() & "','" & _
                                                                                                         Me.rfvCity.ClientID() & "','" & _
                                                                                                         Me.ddlState.ClientID & "','" & _
                                                                                                         Me.rfvZipCode1.ClientID & "','" & _
                                                                                                         Me.rfvResZipCode5Digits.ClientID() & _
                                                                                                         "');"

                  ChkAgree.Attributes.Add("onclick", residentialAddressValidatorsCheck)
                  ScriptManager.RegisterStartupScript(Page, Page.GetType(), "HideAddress", residentialAddressValidatorsCheck, True)

JAVASCRIPT:

function ResidentialAddressValidatorsCheck(objrfvHouse, objrfvStreetName, objrfvAddress, objrfvtxtResidentialCity, objrfvCity, objddlState, objrfvZipCode1, objrfvResZipCode5Digits)
{
    var rfvHouse = document.getElementById(objrfvHouse);
    var rfvStreetName = document.getElementById(objrfvStreetName);
    var rfvAddress = document.getElementById(objrfvAddress);
    var rfvtxtResidentialCity = document.getElementById(objrfvtxtResidentialCity);
    var rfvCity = document.getElementById(objrfvCity);
    var ddlState = document.getElementById(objddlState);
    var rfvZipCode1 = document.getElementById(objrfvZipCode1);
    var rfvResZipCode5Digits = document.getElementById(objrfvResZipCode5Digits);


    if (someCondition == "True")
    {
                ValidatorEnable(rfvHouse, false);
                ValidatorEnable(rfvStreetName, false);
                ValidatorEnable(rfvAddress, true);
                ValidatorEnable(rfvtxtResidentialCity, true);
                ValidatorEnable(rfvCity, false);
                ValidatorEnable(rfvZipCode1, true);
                ValidatorEnable(rfvResZipCode5Digits, true);
    }
}
0
Jaydev RathodSr. Software EngineerCommented:
hi,
 Call below function on button OnClientClick event or call when you want to check your validation.

 OnClientClick="javascript:Page_ClientValidate();"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ArikkanAuthor Commented:
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.