How to validate form field using Jquery in

In this post i am going to show how to validate form field using Jquery in aspdotnetcodebook
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">

    <script src="scripts/jquery.js" type="text/javascript"></script>

    <style type="text/css">
            float: left;
            width: 120px;
            width: 200px;
            color: red;
            padding-left: 10px;
            padding: 5px;

    <script type="text/javascript">
        $(document).ready(function() {
            $('#btnLogin').click(function(event) {
                $('.textbox').each(function() {
                    var data = $(this).val();
                    var len = data.length;
                    if (len < 1) {
                    else {

    <form id="form1" runat="server">
                <span class="label">User Id *</span>
                <asp:TextBox ID="txtUserName" runat="server" CssClass="textbox"></asp:TextBox>
                <span class="error">This field cannot be blank</span></div>
                <span class="label">Password *</span><asp:TextBox CssClass="textbox" ID="txtPassword"
                    TextMode="Password" runat="server"></asp:TextBox><span class="error"> This field cannot
                        be blank</span></div>
            <asp:Button ID="btnLogin" runat="server" Text="Login" />

No comments:

Post a Comment