Thursday, May 2, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  187] [ 5]  / answers: 1 / hits: 103802  / 15 Years ago, wed, july 1, 2009, 12:00:00

What is the best way to determine if a form on an ASPX page is valid in JavaScript?


I am trying to check the validation of a user control that was opened using the JavaScript window.showModalDialog() and checking the 'Page.IsValid' property on the server side does not work. I am using ASP.NET validation controls for page validation.


More From » asp.net

 Answers
36

If I have a page that is using a bunch of ASP.NET validation controls I will use code similar to the following to validate the page. Make the call on an input submit. Hopefully this code sample will get you started!



    <input type=submit value=Submit onclickValidatePage(); />

<script type=text/javascript>

function ValidatePage() {

if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
}

if (Page_IsValid) {
// do something
alert('Page is valid!');
}
else {
// do something else
alert('Page is not valid!');
}
}

</script>

[#99213] Thursday, June 25, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mira

Total Points: 460
Total Questions: 108
Total Answers: 99

Location: American Samoa
Member since Fri, Aug 26, 2022
2 Years ago
mira questions
;