问题描述
我刚刚发现我的表单没有提交时,我提交的元素的名称=提交属性。当我将该名称更改为其他名称时,它完美无缺!
我正在使用parsley.remote.min.js *版本2.0.3 - 已建好Mon Jul 21 2014 11:58:33
对不起,我现在不能提供代码,我只是想把它抛出去。是否可能我做错了什么?
当您命名表单元素submit时,您无意中覆盖了表单的用输入对象提交
方法。例如,用这个:
< form id =testForm>
< input type =textname =testInput/>
< / form>
您现在可以通过表单对象的属性按名称访问输入元素:
var testInput = document.getElementById('testForm')。testInput;
表单有一个 submit()
方法可以以编程方式调用(与点击按钮或输入submit类型调用的是相同的):
document.getElementById ( '了testForm')提交();
也许现在你可以通过命名表单元素submit来看到问题 - 由于 submit()
不再存在,它已被重新定义为返回对提交按钮的引用的属性。
更多解释可在此处找到:
I just discovered that my form isn't submitting when i give the submit element the name="submit" attribute. When I change the the name to something else, it works perfectly!
I am using parsley.remote.min.js * Version 2.0.3 - built Mon Jul 21 2014 11:58:33
Sorry I cannot provide code right now, I just wanted to throw that out there. Is it possibly I am doing something wrong?
When you name a form element "submit", you inadvertently override the form's submit
method with an input object. For example, with this:
<form id="testForm">
<input type="text" name="testInput" />
</form>
You can now access the input element by name through a property on the form object:
var testInput = document.getElementById('testForm').testInput;
Forms have a submit()
method you can call programmatically (which is the same one invoked by clicking a button or input of "submit" type):
document.getElementById('testForm').submit();
Perhaps now you can see the problem by naming a form element "submit" -- you're taking away the form's ability to be submitted because submit()
no longer exists -- it's been redefined as a property that returns a reference to your submit button.
More explanation is available here:
这篇关于当提交按钮具有名称=“提交”时,欧芹形式不提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!