<script type="text/javascript">
// form表单提交
function submitForm() {
if(!checkSensitive()){
alert("包含敏感字段,请重新提交");
return false;
}
$("form").submit();
}
// 聚焦事件,初始化input颜色
$(document).ready(function() {
$("input[type=text]").focus(function () {
$(this).css("color", "");
});
});
// 检查敏感词
function checkSensitive() {
// $("input[type=text]").css("color","");
var flag = true;
var keywords = ["敏感词", "敏感词", "敏感词", "敏感词", "敏感词"];
$("input[type=text]").each(function () {
for (var i = 0; i < keywords.length; i++) {
if ($(this).val().indexOf(keywords[i]) != -1) {
$(this).css("color","red");
flag = false;
}
}
});
return flag;
}
</script>
“`