BigBlondeViking
BigBlondeViking

Reputation: 3963

On blur of ASP.NET form field, call validator(s) on that one field

I have a form that has some standard ASP.NET validators and some custom validators.

I know how to force the whole page to validate.

But how on blur of a form field can I force the validator(s) that are looking at the field fire, not all validations on the page.

I expect I am missing some little trick. :(

Upvotes: 2

Views: 1971

Answers (2)

BigBlondeViking
BigBlondeViking

Reputation: 3963

Well looks like I answered my own question, with some help from George, and the Intertubes.

After seeing this post: I looked at the DOM in Firebug and found the array of Validators. Then it was a matter of getting the right ones, and calling the ValidatorValidate(validator) method.

function callMyValidators() {
    // Clean Up Infragistics Ids
    var cleanid = this.id.replace(/^igtxt/i,"");

    for (var i = 0; i < Page_Validators.length; i++) {
        if (Page_Validators[i].controltovalidate === cleanid) {
            ValidatorValidate(Page_Validators[i]);
        }
    }
}

Upvotes: 3

George
George

Reputation: 7944

Use the function: ValidatorValidate(val)

http://msdn.microsoft.com/en-us/library/aa479045.aspx

Upvotes: 1

Related Questions