Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check Page.Validate() on client side (JavaScript) in ASP.Net?

I want to check page validation on client side, like Page.Validate() but it's a server side method. Is there any client side function which can work like Page.Validate() with JavaScript?

like image 799
Azhar Avatar asked Oct 19 '10 09:10

Azhar


People also ask

What is JavaScript page Clientvalidate?

Page_ClientValidate() will work. It returns true if the page was valid and it works fine. If you are using ASP.NET 2.0, pass the validation group name as a parameter. E.g.

How JavaScript is used for client side validation?

Client-side validation is visible to the user. It involves validation on input forms through JavaScript. For example, if input is submitted for a phone number or email, a JavaScript validator would provide an error if anything is submitted that does not conform to a phone number or email.

How can use JavaScript in asp net web form?

Where to write JavaScript code in ASP.Net Form? You can write the JavaScript code in the ASP.Net Page in the following sections. You can write the JavaScript code in the head section, it is the recommended way to write the code, the code must be enclosed in the following syntax: <head id="Head1" runat="server">


1 Answers

Page_ClientValidate() will work. It returns true if the page was valid and it works fine.

If you are using ASP.NET 2.0, pass the validation group name as a parameter.
E.g.

if(Page_ClientValidate("SomeValidationGroup"))      alert('its valid'); 

Otherwise if there is no validation group Page_ClientValidate("") will handle it.
E.g.

if(Page_ClientValidate(""))      alert('its valid'); 
like image 107
Azhar Avatar answered Sep 21 '22 21:09

Azhar