ASP. NET jQuery instance 3 (prevents copying, cutting, and pasting events in TextBox)

Source: Internet
Author: User

When a user needs to enter some sensitive information such as passwords, credit card information, and bank accounts, the user prefers to manually press the data through the keyboard, instead of copying and pasting the data through the clipboard.

Let's take a look at the effect after implementation:
Enter New Password

Copy the new password. The following dialog box is displayed.

Interface code
Copy codeThe Code is as follows:
<Body>
<Form id = "form1" runat = "server">
<Div align = "center">
<Fieldset style = "width: 400px; height: 180px">
<Table cellpadding = "3" cellspacing = "3" border = "0">
<Tr>
<Td colspan = "2" class = "header">
Change Password
</Td>
</Tr>
<Tr>
<Td>
<Asp: Label ID = "lblCurrentPwd" Text = "current password:" runat = "server"> </asp: Label>
</Td>
<Td>
<Asp: TextBox ID = "txtCurrentPwd" Width = "200px" runat = "server" TextMode = "Password"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td>
<Asp: Label ID = "lblNewPwd" Text = "New Password:" runat = "server"> </asp: Label>
</Td>
<Td>
<Asp: TextBox ID = "txtNewPwd" Width = "200px" runat = "server" TextMode = "Password"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td>
<Asp: Label ID = "lblConfirmNewPwd" Text = "confirm new password:" runat = "server"> </asp: Label>
</Td>
<Td>
<Asp: TextBox ID = "txtConfirmNewPwd" Width = "200px" runat = "server" TextMode = "Password"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td>
</Td>
<Td>
<Asp: Button ID = "btnSubmit" runat = "server" Text = "Submit"/> <asp: Button ID = "btnReset" runat = "server"
Text = "reset"/>
</Td>
</Tr>
</Table>
</Fieldset>
</Div>
</Form>
</Body>

Script code
Copy codeThe Code is as follows:
<Head runat = "server">
<Title> Recipe3 </title>
<Script src = "Scripts/jquery-1.4.1-vsdoc.js" type = "text/javascript"> </script>
<Style type = "text/css">
. Header
{
Background-color: Gray;
Font-weight: bold;
Font-size: large;
}
</Style>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("Input: password"). bind ("copy cut paste", function (e) {// Add copy, cut, and paste events consecutively with spaces
E. preventDefault (); // block the default behavior of the event
Alert ("copying, cutting, and pasting have been disabled in the text box ");
});
});
</Script>
</Head>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.