How to Invoke required field validator through JavaScript in

So, recently I came across a problem where I had wanted to invoke required filed from JavaScript. Fortunately, there is a way - and it’s pretty easy to do! Let’s take a look.
In this post, I will show you how to invoke the required field validator through javascript in

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReqJs.aspx.cs" Inherits="ReqJs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <script type="text/javascript">
        function PerformCheck() {
            if (Page_ClientValidate()) {
                //Do some more stuff here
                alert("Page Is Valid");

    <form id="form1" runat="server">
        <asp:TextBox runat="server" ID="txtFirstName"></asp:TextBox>
        <asp:RequiredFieldValidator ErrorMessage="*" Text="Please Enter first name" ControlToValidate="txtFirstName"
            runat="server" /><br />
        <asp:TextBox runat="server" ID="txtLastName"></asp:TextBox>
        <asp:RequiredFieldValidator ErrorMessage="*" Text="Please enter last name" ControlToValidate="txtLastName"
            runat="server" /><br />
        <input type="submit" id="btnSubmit" onclick="PerformCheck();" value="Validate" />
Next Post Previous Post
No Comment
Add Comment
comment url