开发者

Disabling Ctrl+C

While registering to a website, it has 2 fields. Email and email confirmation. The thing is, people are copying what they're writing on first field and pasting on the other field. I'd like to disable it, is it possible?

<h:inputText id="email" value="#{registerBean.email}" maxlength="6开发者_如何学C0" />


One of the most important things to track in UI design (if you care about a consistent user interface) is all of the nuances which people come to expect.

If you disable the "copy" hot key sequence, then many people will feel frustration because your interface doesn't conform with the nuances that hold for the rest of the operating system. While I understand why you might want to do this, that's not going to convince people that your code isn't broken. After all "Ctrl+c" works every where else.

Once you deviate from enforcing expected UI control nuances, then you need to indicate where the nuance is permitted and where it is denied. That's the DEFINITION of an inconsistent user interface. As the user isn't going to have you there to explain the "why" when the UI does something that they don't expect, they will invariably consider it a bug. If they did have you there telling them why they couldn't do something allowed in every other part of their operating system, they will invariable consider you overzealous in enforcing something stupid which everyone else allows.

The solution is to use a better solution. Enforce what is already expected to reduce the learning curve, or select something (OpenID has been mentioned) that sidesteps the objectionable task(s).


This page suggests the following solution:

<script language="javascript">

function onKeyDown() {
    // current pressed key
    var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();

    if (event.ctrlKey && (pressedKey == "c" || pressedKey == "v")) {
        // disable key press porcessing
        event.returnValue = false;
    }
} // onKeyDown

</script>

I should add though, that in general it is impossible for a webpage to tell the client browser to "disable cut and paste".

Btw, I never use Ctrl+C for copying text. I'm on XWindows so simply selecting the text will copy it. If I'm on a windows system I usually do Ctrl+Insert


I'm thinking that this question is pretty similar to yours: Disable pasting text into HTML form

My summary of the answers: You can, but it's messy and it's poor UI design. They also have some good suggestions for better UI design.


Please don't do that. I hate having to copy my email address, and if I actually had to type it twice, I would just leave unless I was being forced to make an account for some reason.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜