Tuesday, December 1, 2009

Client Side Validation with JavaScript in ASP.NET

This simple program will guide how to do client side validation of Form in JavaScript.

In this just make a form as follows:

Name :
Email :
Web URL :
Zip :

Now on the source code of this form in script tag write the following code:

And in code behind file just write the below code.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
btnSubmit.Attributes.Add("onclick", "return validate()")
End Sub

Now you will get a form with proper validation.

I hope this is going to help you.