2012-02-01 3 views
0

양식 알림을받을 수있는 자습서 나 스크립트를 아는 사람이 있는지 궁금합니다.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을 올바르게 코딩 했습니까?

<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> 

나는 작동하는 스크립트를 발견

<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> 

은 .. 그러나 나는 지금 여러 specialwords을 위해 일해야합니다. 나는 마크가 말한 것을하려고 노력했다.

var specialWords = ["hello", "goodbye"]; 

그러나 wouldnt는 일한다. 어떤 제안.

+1

문제를 명확하게 정의하십시오. 어떤 메시지를 생각해 내고 싶습니까? 너는 무엇을 하려니? – AlphaMale

+0

위 답변에서 jquery 코드를 사용하고 경고를받는 값과'specialWords' 배열을 변경할 수 없습니까? 아래의 코드는 아무 것도 추가하지 않는 것 같습니다. 실제로 어떤 경우에는 작동하지 않습니다. 사용자가 마우스 오른쪽 버튼으로 붙여 넣거나 입력 상자가 두 개 있습니다. –

답변

1

표준 자바 스크립트 팝업의 리소스는 http://www.w3schools.com/js/js_popup.asp입니다. 사용자 지정 스타일링을 적용 할 수 없으며 동기식 (브라우저가 팝업이 제거 될 때까지 아무 것도 할 수 없음)이지만 사용하기 쉽고 사용자주의를 끌기 때문에 어떤 사람들은 좋아하지 않습니다!

정확히 무엇이 필요한지 잘 모르겠지만 다음 예제 코드가 도움이 될 수 있습니다. 사용자가 텍스트 필드에 "hello"또는 "goodbye"를 입력하면 경고가 트리거됩니다 (필요한 경우 배열!).

<form id="theForm"> 
    <input type="text" /> 
</form> 

그런 다음 다음과 같은 jQuery 코드가 그것을 수행해야합니다 : 저는 여기에 다음과 같은 마크 업을 포함 있으리라 믿고있어

var specialWords = ["hello", "goodbye"]; 
$(function(){ 
    $('#theForm').on("change keyup", "input[type='text']", function(event){ 
     var inputValue = $(this).val(); 
     if($.inArray(inputValue, specialWords) > -1){ 
      alert("There may be a conflict of interest..."); 
     } 
    }); 
}); 

편집 : 그 jQuery의 on 기능은 버전 1.7과 같다주의, 이전 버전을 사용하는 경우 live 또는 delegate을 사용해보세요.