How to implement validations on form controls using javascript before a postback occurs.

If we are using submit button in the form, we have to validation data before sending to the server. For this on submit we will call the javascript method. from the method we will return true or false based on the validation result.

<!DOCTYPE html>
<html xmlns="">
    <script src=""></script>
    <script type="text/javascript">
        function Validate() {
            //Need to do validations here. 
            //If any thing fails we have to return false other wise request go to server
    <form onsubmit="return Validate()">
        ... all controls will go here with submit button...

If you have any queries or suggestions, please feel free to ask in comments section.
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar