4

I am validating some .net validators in javascript on the button client click event.

if (typeof (Page_Validators) != "undefined") {

            for (var i = 0; i < Page_Validators.length; i++) {

                    ValidatorValidate(Page_Validators[i])
                    if (!Page_Validators[i].isvalid) {

                        alert("not valid");
                    }
                    else {
                        alert("valid");
                    }                    
            }
        }

But if i have more than one validation groups in the same page, then on the button click of one button will validate all the validators in the page, not the validators associated with that button's validation group.

So is there any way to only validate validators of a particular validation group from javascript?

1 Answer 1

6

Try

Page_ClientValidate('ValidationGroup');
Sign up to request clarification or add additional context in comments.

4 Comments

actually this is written inside a jquery click event of a button. So validation group will change on each click. Is there any way to get the validation group of a button on its click event from javascript.
@mahesh: Check out this article - weblogs.asp.net/gurusarkar/archive/2010/12/28/…
@JamesJohnson : But how we get the validation group of a button in this case. We took controls/validators validation group, but how to get buttons validation group.
mmm - not easy - it isn't a property of the button. It's embedded in the JavaScript of the page. This post is helpful eggheadcafe.com/community/asp-net/17/10178886/…. You woud either assign it yourself in Javascript then it would be available or it is available in the button click event allegdely. I would take a control you know is in the same validation group as the button and use that - not ideal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.