想知道是否有人知道任何教程或腳本可以獲取表單通知。用於HTML的通知警報消息
我想要的是當某人在表單中鍵入特定關鍵字時,它需要提供一條消息。
我想要做的是當查看器將以下關鍵字輸入到表單中時;
Medlab Central
Medlab Wanganui
Naylor Lawrence
Doughboys Bakery Limited – owners surname ‘Funke’
Denver Stockfeeds Limited – owners surname ‘Currie’
Midland Civil Limited – Miles and Vicky Worsley
Arran Trust – Stephen and Mary Barr
Roadmarking Services Limited – Karen and Kelly halligan
Steeds Pharmacy Ltd
我想要一個彈出窗口的通知,說'可能存在利益衝突。請稍等,從Proa聽到他們如何幫助'
有一個快速去,這是HTML的正確編碼;
<form id="theForm">
<input type="text" />
<input type="submit" value="Send Email">
</form>
</body>
<script>
var specialWords = ["hello", "goodbye"];
$(function(){
$('#theForm').on("change keyup", "input[type='text']", function(event){
var inputValue = $(this).val();
if($.inArray(inputValue, specialWords) > -1){
alert(inputValue + " is a special word!");
}
});
});
</script>
</html>
我發現了一個腳本,工程..
<script language="JavaScript">
var nav=navigator.appName;
var ns=(nav.indexOf("Netscape")!=-1);
if(ns){
if(document.layers){
document.captureEvents(Event.KEYPRESS);
document.onkeypress = cheat;
}
if(document.getElementById){
document.onkeypress = cheat;
}
}
else
{document.onkeypress = cheat;}
var SpecialWords = "here"
var SpecialLetter = 0;
var vcheat = false
function cheat(keyStroke)
{
var eventChooser = (ns)?keyStroke.which: event.keyCode;
var which = String.fromCharCode(eventChooser).toLowerCase();
if(which == SpecialWord.charAt(SpecialLetter)){
SpecialLetter++;
if (SpecialLetter == SpecialWord.length) alert("There may be a conflict of interest. Please wait to hear from PROA regarding how they can help")
}
else {SpecialLetter = 0;vcheat = false}
}
</script>
但是我現在需要爲多個specialwords工作。我試圖做什麼馬克說這是
var specialWords = ["hello", "goodbye"];
但不會工作。有什麼建議麼。
請明確你的問題。你想要什麼信息?你想做什麼? – AlphaMale 2012-02-01 06:11:21
難道你不能只使用上面的jquery代碼(從我的答案)並更改獲取警報的值和'specialWords'數組?下面的代碼似乎沒有增加任何內容 - 事實上它在某些情況下不起作用 - 例如用戶右鍵點擊粘貼東西,或者有兩個輸入框等。 – 2012-02-03 08:36:14