我收到在Firefox錯誤控制檯的錯誤「錯誤:submitSearchForm沒有定義」Firefox的JavaScript錯誤函數「未定義」在IE
這是我該功能
編輯代碼:加入全碼
function submitSearchForm(action,iskeyDown) {
var oneEntered = false;
if(iskeyDown == null || iskeyDown == 'undefined'){
copyAndValidate("dobFrom", "searchCriteria.dob", "date");
copyAndValidate("dobTo", "searchCriteria.dobTo", "date");
copyAndValidate("dodFrom", "searchCriteria.dodFrom", "date");
copyAndValidate("dodTo", "searchCriteria.dodTo", "date");
copyAndValidate("searchCriteria.age", "searchCriteria.age", "integer");
}else{
copyAndValidate("dobFrom_date", "searchCriteria.dob", "date");
copyAndValidate("dobTo_date", "searchCriteria.dobTo", "date");
copyAndValidate("dodFrom_date", "searchCriteria.dodFrom", "date");
copyAndValidate("dodTo_date", "searchCriteria.dodTo", "date");
copyAndValidate("searchCriteria.age", "searchCriteria.age", "integer");
}
var elements = document.SearchForm.getElementsByTagName("INPUT");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (element != null && element.getAttribute("group") == 'searchCriteria') {
if (!isEmpty(element.value)) {
oneEntered = true;
break;
}
}
}
if (oneEntered)
{
if (validate(document.SearchForm)) {
document.SearchForm.action.value = action;
document.SearchForm.submit();
}
}
else {
alert("<%= bpt.getValue("CCT_ATLEASTONE_MSG") %>");
}
}
按鈕
只是再次說的一切在IE中正常工作,使代碼是正確的
編輯:VALIDATION.JS的validate()
function validate(thisForm) {
window.event.returnValue = false;
formToValidate = thisForm;
var ret = true;
var validationErrors = new Array();
// get the validateable items
// var validateThese = getValidationItems(thisForm.childNodes);
var validateThese = getValidationItems(thisForm);
//printValidationArray(validateThese);
// validate them
for (var i = 0; i < validateThese.length; i++) {
var validationItem = validateThese[i];
var validationError = validateMe(validationItem);
if (validationError != "") {
validationErrors[validationErrors.length] = validationError;
}
}
// check for validation errors
if (validationErrors.length > 0) {
var errors = "";
for (var j = 0; j < validationErrors.length; j++) {
errors += validationErrors[j] + "\n";
}
alert("Validation Errors:\n" + errors);
ret = false;
} else {
ret = true;
}
return ret;
}
這是完整的代碼?代碼使用的window.event在哪裏? – David 2010-12-08 16:23:49
我刪除了關於window.event的一點,因爲那不是我的問題。我在詢問submitsearchform。 – code511788465541441 2010-12-08 16:27:20
@user:好的。什麼樣的JavaScript導致_「submitSearchForm未定義」_錯誤?另外,爲什麼在你的`if(...)`語句中多了一些大括號?這在語法上是無效的。 – 2010-12-08 16:29:14