Monday, April 9, 2007

See if page is valid from JavaScript

I did a little digging through the javascript code that ASP.Net uses to do its client-side (javascript) validation to figure out how ASP.Net knows if the page or group is valid or not before submitting the form. Here is the hack you can use to do it yourself. // a empty string means page. var validationGroupName = "";

if (typeof(Page_ClientValidate) == 'function') { var validationResult = Page_ClientValidate(validationGroupName); if (validationResult == true) { // do your cool javascript stuff here. This will only happen if the page or group is valid } }

No comments: