views:

304

answers:

2

I have several tabs that are loaded via ajax, and each one has a set of validators. I want to allow the user to change tabs only if the tab is valid

I thought setting a validationgroup to the validators and then check for the specific group like this, would work:

function validatePage(group) {
    return Page_ClientValidate(group);
}

However, when I call the function, it always returns true. Can anyone see what I'm doing wrong?

I check it like this

alert(validatePage("presentaciones"));

And I have some validators:

// (...)
<asp:TextBox ValidationGroup="presentaciones" id="txtDescription" runat="server" Text='<%# Eval("Description") %>' MaxLength="50" />
<asp:RequiredFieldValidator ID="DescriptionRequiredFieldValidator" runat="server" ControlToValidate="txtDescription" SetFocusOnError="true" ValidationGroup="presentaciones" ErrorMessage="Debe ingresar una descripción" Display="Dynamic" />
// (...)
A: 

I have made groups work server-side with Page.Validate(group) but I wasn't aware this could be done client-side. Perhaps you need to implement a custom validation control that checks the status of each tab.

Dave Anderson
A: 

My guess is that the validation scripts are not being wired up. In your function do an alert((typeof(Page_Validators) == "undefined")) and see if it displays true. You said you are loading the tabs via ajax. You may want to see if placing a validator on the page somewhere will help wire up the validation scripts.

The other thing to watch for is Firefox and legacy rendering mode....client side just plain does not work in that scenario.

wulimaster