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>