Validation through Javascript

Introduction: Validation through Javascript is used to provide security or better performance of code.  First we take aspx page to run validation through javascript. We take two Textbox, two Labels and a button. Then we arrange them like below figure.

validation through javascript

we write the following javascript code for validation

<script type="text/javascript">
        function validate()
        {
            var t = document.getElementById('TextBox1').value;
            if (t == "") {
                alert("Employ Id is Mandatory");
      }    
        }
    </script
>

Output: when we run this program there will be one message display if we leave blank column after click on button.
javascript validation

Ebook Download
View all
Learn
View all