Click here to Skip to main content
Click here to Skip to main content

How to mask a textbox using jquery?

, 10 Jul 2014
Rate this:
Please Sign up or sign in to vote.
I am trying to mask a textbox using jquery and it has errors. I am using VS2010 ASP.Net Blank Web Form and C#. I have a code that is the html code for the page. What am I doing wrong?<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Testcommas.aspx.cs"...
I am trying to mask a textbox using jquery and it has errors. I am using VS2010 ASP.Net Blank Web Form and C#. I have a code that is the html code for the page. What am I doing wrong?
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Testcommas.aspx.cs" Inherits="TestNumberCommas.Testcommas" %>
<script src="<%=Page.ResolveUrl("~")%>"Style/javascript/jquery-1.7.1.js" type="text/javascript"></script>
<!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 runat="server">
    <title></title>
    <script src="jquery.js" type="text/javascript"></script>
    <script src="jquery.maskedinput.js" type="text/javascript"></script>
    <script type='text/javascript'>
        jQuery(function ($) {
            $("#TextBoxY").mask("999,999,999,999");
        });
 
    </script>
 
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 245px;
        }
        .style3
        {
            width: 66px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    <table class="style1">
        <tr>
            <td class="style3">
                 </td>
            <td class="style2">
                <asp:TextBox ID="TextBoxINST_ID" runat="server"></asp:TextBox>
            </td>
            <td>
                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Submit" 
                    Width="100px" />
            </td>
        </tr>
        <tr>
            <td class="style3">
                Hourly</td>
            <td class="style2">
                <asp:TextBox ID="TextBoxH" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style3">
                Yearly</td>
            <td class="style2">
                <asp:TextBox ID="TextBoxY" runat="server" Width="180px" 
                    AutoCompleteType="Email"></asp:TextBox>
               
            </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style3">
                 </td>
            <td class="style2">
                <asp:TextBox ID="TextBoxadd" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style3">
                 </td>
            <td class="style2">
                <asp:TextBox ID="TextBoxadd1" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style3">
                 </td>
            <td class="style2">
                <asp:TextBox ID="TextBoxadd2" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style3">
                 </td>
            <td class="style2">
                <asp:TextBox ID="TextBoxadd3" runat="server" Width="180px" AutoPostBack="True" 
                    ontextchanged="TextBoxadd3_TextChanged"></asp:TextBox>
            </td>
            <td>
                 </td>
        </tr>
        <tr>
            <td class="style3">
                 </td>
            <td class="style2">
                <asp:TextBox ID="TextBoxadd4" runat="server" Width="180px"></asp:TextBox>
            </td>
            <td>
                 </td>
        </tr>
    </table>
    </form>
</body>
</html>
 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Computer Wiz99

United States United States
No Biography provided

Comments and Discussions

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 10 Jul 2014
Article Copyright 2014 by Computer Wiz99
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid