【问题标题】:why is web2py custom form, submitting even without {{=form.custom.submit}}?为什么 web2py 自定义表单,即使没有 {{=form.custom.submit}} 也提交?
【发布时间】:2017-02-20 03:56:04
【问题描述】:

我不知道发生了什么,但即使没有 {{=form.custom.submit}} 代码,我的表单也会提交。


        {{=form.custom.begin}}
            <div>{{=form.custom.widget.id}}</div>
            <div>{{=form.custom.widget.details}}</div>

            <div id="submit"><button></button></div>
        {{=form.custom.end}}

请注意,我输入的只有 &lt;div id="sc"&gt;&lt;button&gt;&lt;/button&gt;&lt;/div&gt;

发生了什么,请告诉我如何解决这个问题。

【问题讨论】:

    标签: forms button form-submit web2py


    【解决方案1】:

    按钮元素的默认类型是“提交”,因此您的按钮标签充当提交按钮。如果您不希望它充当提交按钮,则将其“类型”属性显式设置为“提交”以外的其他内容,例如“按钮”或“重置”。

    <button type="button"></button>
    

    【讨论】:

    • 我之前确实将类型设置为按钮,并且它起作用了,我希望 jquery 执行自定义提交的功能,我输入了 'jQuery.ajax("{{=form. custom.submit}}")';这可能吗?
    • 以上是否回答了您实际提出的问题?如果是这样,请随时接受它,然后提出一个关于 Ajax 表单提交的单独问题。
    猜你喜欢
    • 2013-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-13
    • 1970-01-01
    • 2020-09-23
    • 2013-06-14
    • 1970-01-01
    相关资源
    最近更新 更多