0

Limesurvey (2.05+) に関するアンケートを作成しました。回答者に勤務先の会社名を尋ねます。「拒否された」、「拒否された」、「開示できない」などの単語を入力した場合にアラートがポップアップして、続行できないようにしたい. Limesurveyフォーラムで彼らに連絡したところ、試してみるためのコードがいくつか提供された. . コードは Safari と IE では機能しますが、Chrome や Firefox では機能しません。Limesurvey の技術者が彼の側でテストしたところ、彼はそれが彼の Chrome で動作したと述べました。すべてのキャッシュをクリアし、ブラウザーを再起動し、コンピューターを再起動しました... 職場の VPN の外で試しました... 他の人に試してもらいました...無駄に。

コードは次のとおりです。

$(document).ready(function() {	
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		// Define the disallowed strings and allert text
		var disallowed = ['refused', 'none of your business', 'nunya'];
		var alertText = 'You have entered an invalid string!';
 
		// Interrupt the Next/Submit click
		$('#movenextbtn, #movesubmitbtn').bind('click', function () {
			var thisInput = $('input.text', thisQuestion);
			var thisVal = thisInput.val();
			thisInput.removeClass('disallowed-string');
 
			// Loop through all disallowed strings
			$(disallowed).each(function() {
				// If disallowed string found in input value
				if(new RegExp('\\b'+this+'\\b', 'i').test(thisVal) == true) {
					thisInput.addClass('disallowed-string'); // Add a class
					alert(alertText); // Pop up alert
					return false; // Exit the loop
				}
			});
 
			// Abort the Next/Submit if we found a disallowed string
			if(thisInput.hasClass('disallowed-string')) {
				return false;
			}
		});
 
	});

このコードについて、Firefox や Chrome が気に入らないのはどのような点ですか? Lynda.com コースから、Chrome でも動作しないが Safari では動作する他のコードがありました。jquery-validate プラグインを試すことはできますか? それを自分の状況にどのように適応させることができますか?

どんな助けでも大歓迎です。アンケートにアクセスして確認する必要がある場合はお知らせください。

前もって感謝します。

J

4

0 に答える 0