您必须在页面上包含该代码才能使其正常工作。
您以 as 链接的文件miscScripts.js
是无效的 javascript。
它开始于:
<!--
// function to swap inner DIVs in homepage left content
function showDiv(div_number) {
并以
});
-->
它应该是:(删除页面级别的评论标记)
// function to swap inner DIVs in homepage left content
function showDiv(div_number) {
并以
});
仅供参考,我在任何文件中都看不到“提交”代码,它在您页面上的哪个文件中?
这些是该页面源上的链接:
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="theScriptsStyles/miscScripts.js"></script>
<script type="text/javascript" src="theScriptsStyles/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="theScriptsStyles/jquery.hoverIntent.minified.js"></script>
<script type="text/javascript" src="theScriptsStyles/jquery.naviDropDown.1.0.js"></script>
EDIT2:好的,我花了一点时间查看您的代码,在某些地方似乎有点奇怪,我在您的目标中做了一些粗略的假设并重新编写了您的代码以产生这个:
注意:当用户更正表单时,我使用更改事件来关闭红色错误。您可以使用它,也可以根据需要进行修改。
$("form#myform").submit(function (e) {
var myform = $(this); //done this way in case selector has multiple forms
var invalidCount = myform.data('hasinvalidentries'); //check validation
if (invalidCount === 0) { //0 not falsy value as 0 set errors check below
return; // let the event bubble away
}
e.preventDefault(); //not check so prevent submit
var mysubmitButton = myform.find("input[type=submit]");
mysubmitButton.prop("disabled", true).data('buttontext', mysubmitButton.val()).val('processing...');
document.body.style.cursor = "wait";
var html = '';
var submitme = true;
$('input[type=radio]').each(function () {
var nam = $(this).attr('name');
var radioGroup = myform.find('input:radio[name="' + nam + '"]');
if (!radioGroup.is(':checked')) {
radioGroup.next('label').addClass('error');
if (html.indexOf(nam) < 0) {
html += nam + ' group not checked' + '<br />';
}
submitme = false;
}
});
if (submitme) {
$('.errorDiv').hide();
myform.data('hasinvalidentries', 0).submit();
} else {
$('.errorDiv').empty().append(html).show().addClass('error');
return submitme;
}
});
/* Check to set the radio group as no errors when change one as one will have to be selected.
Still possible if I manually using code set all to unselected, but acts on users changes at least.
*/
$('form#myform').on('change', 'input:radio', function () {
var myform = $(this).parents('form'); //done this wa in case selector incudes multiple forms
var errorCount = myform.find('.error').length;
if (errorCount) {
var nam = $(this).attr('name');
myform.find(':radio[name="' + nam + '"]+label').removeClass('error');
var mysubmitButton = myform.find("input[type=submit]");
mysubmitButton.removeProp("disabled").val(mysubmitButton.data('buttontext'));
errorCount = myform.find('.error').length;
myform.data('hasinvalidentries', errorCount);
}
});
这是该代码的一个工作示例:http: //jsfiddle.net/whNtP/