This could probably be rolled into a function or, better, a jQuery plugin but no time today...
Assuming the question is a short-text, add something like this to the question source. It will interrupt the Next/Submit function and search the text input for your disallowed strings. If found, an alert is popped up, a class is applied to the input and the Next/Submit function is aborted.
Code:
<script type="text/javascript" charset="utf-8">
$(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(i) {
// 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;
}
});
});
</script>
You can add something like this to the end of template.css for the disallowed class:
Code:
input.disallowed-string {
background: pink;
border: 1px solid red;
}