Navigation

Search

Categories

On this page

Using jQuery to Restrict Textbox Content to Alphabetic Characters

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 245
This Year: 51
This Month: 0
This Week: 0
Comments: 0

Sign In
Pick a theme:

# Thursday, June 03, 2010
Thursday, June 03, 2010 7:11:48 PM (GMT Daylight Time, UTC+01:00) ( jQuery )


Here is a working demo of this example.

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Alpha Characters Only</title>


<script src="http://code.jquery.com/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $(".gv input.rate").bind('keyup blur', function (e) {
            if (this.value.match(/[^a-zA-Z ]/g)) {
                this.value = this.value.replace(/[^a-zA-Z ]/g, '');
            }
        });
    });
</script>
</head>

<body>
<form runat="server" id="form1">

<asp:SqlDataSource
        id="srcMovies"
        ConnectionString="<%$ ConnectionStrings:MyDatabase %>"
        SelectCommand="SELECT Id,Title,Director FROM Movies"
        Runat="server" />


        <h3>Using a Gridview</h3>
<div class="tableDiv">
        <asp:GridView
        id="grdMovies"
        DataSourceID="srcMovies"
        DataKeyNames="Id" 
        AutoGenerateColumns="false"
        Runat="server" class="gv">

        <Columns>
        
        <asp:BoundField DataField="Id" HeaderText="Id" />
        <asp:BoundField DataField="Title" HeaderText="Title" />
        <asp:TemplateField HeaderText="Comments">
        <ItemTemplate>
            <asp:TextBox id="txtComments" runat="server" MaxLength="25" class="rate" />
        </ItemTemplate>
        </asp:TemplateField>
        </Columns>
        </asp:GridView>
        <p id="para"></p>
</div>
</form>

</body>
</html>