次のスクリプトを使用して、フォームの「カット アンド ペースト」を無効にしています。
$(document).ready(function(){
$('.employeeEmailConfirm, .emailConfirm').bind("cut copy paste",function(e) {
alert('thou. shalt. not. PASTE!');
e.preventDefault();
});
});
次のスレッドから取得: How to disable Paste (Ctrl+V) with jQuery?
しかし、隠しdivを表示したい「アラート」を表示したくありません。
ただし、フォームにはラジオ ボタン リストがあり、選択した値に応じて一部のフォーム要素が表示または非表示になります。
$(document).ready(function() {
// attach event to employee radio buttons
$("span.isEmployee").find("input").click(function() {
if ($(this).val() == "1") {
$(".aboutyou").show();
$(".yourdetails").show();
$(".referrer").hide();
$(".security").show();
$(".signup").show();
$("#emailTr").show();
$("#employeeEmailMessage1").show();
$("#employeeEmailMessage2").hide();
$("#employeeEmailRetype").show();
$("#nonemployeeEmail").hide();
$("#nonemployeeEmailRetype").hide();
$("#emailMessageSubBrand").show();
SetEmailEnableDisable(true);
} else {
$(".aboutyou").show();
$(".yourdetails").show();
$(".referrer").show();
$(".security").show();
$(".signup").show();
$("#emailTr").hide();
$("#employeeEmailMessage1").hide();
$("#employeeEmailMessage2").hide();
$("#employeeEmailRetype").hide();
$("#nonemployeeEmail").show();
$("#nonemployeeEmailRetype").show();
$("#emailMessageSubBrand").hide();
SetEmailEnableDisable(false);
}
});
「カット コピー ペースト」スクリプトを表示/非表示ラジオ ボタン リストと組み合わせるにはどうすればよいですか?
私の失敗した試み:
$(document).ready(function(){
$('.employeeEmailConfirm, .emailConfirm').bind("cut copy paste",function(e) {
alert('thou. shalt. not. PASTE!');
$("span.isEmployee").find("input").click(function() {
if ($(this).val() == "1") {
$("#employeeEmailMessage2").show();
} else {
$("#nonemployeeEmailMessage").show();
e.preventDefault();
});
});