2012-11-23 92 views
1

addForm用作表單ID,但表單提交在firefox中不起作用。document.addForm.submit()在Firefox中不工作

$(function() { 
var date = $("#todo_due").val(); 
var text = $("#todo_due").val(); 
    if (date && text) { 
    document.addForm.submit(); 
    } else if (!date && !text) { 
    new Messi('{$LANG.main.todo_validation}', {ldelim}title: '{$LANG.error.error}', titleClass: 'info', modal: true{rdelim}); 
    } else if (!text) { 
    new Messi('{$LANG.main.todo_validation_desc}', {ldelim}title: '{$LANG.error.error}', titleClass: 'info', modal: true{rdelim}); 
    } else { 
    new Messi('{$LANG.main.todo_validation_date}', {ldelim}title: '{$LANG.error.error}', titleClass: 'info', modal: true{rdelim}); 
    } 
}); 
+0

該表單必須針對addform id提交... – user1847416

回答

1

使用

document.getElementById('addForm').submit(); 

$('#addForm').submit(); 

用於跨瀏覽器解決方案。

Internet Explorer中增加了一個全局變量稱爲addForm,因爲你必須具有元素這個ID,但它是一個不正確的,不規範的行爲。

0

你似乎使用jQuery。您可以通過以下方式輕鬆提交表單:

$("#addForm").submit();