本文介绍了直接点击事件之前的表单验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个按钮,我想在直接点击事件fire之前形成验证(客户端)。我尝试了很多方法但失败了。

I have a button,I want to form validation(client side) before direct click event fire.I tryed lots of way but failed.

**我已经设置这样的文本框。

** I already set textbox like this.

 <ext:TextField ID="Ad" runat="server" FieldLabel="Dem ad" Flex="1" AllowBlank="false" CausesValidation="true"> </ext:TextField>

但即使在文本框检查之前仍然直接触发

but still fire direct even before textbox checking

<ext:Button ID="Button1" runat="server" Text="save" Icon="Disk">
                                  <DirectEvents>

                                    <Click OnEvent="Dem">
                                        <Confirmation ConfirmRequest="true"  Title="Title" Message="are u sure you want to update..." />

                                    </Click>

                                </DirectEvents>


                            </ext:Button>


推荐答案

有几个选项。


  1. 您可以从DirectEvent的Before处理程序或从同一个监听器返回false。

  1. You can return false from a DirectEvent's Before handler or from the same Listener.




Ext.NET v2示例



Ext.NET v2 Example

    <ext:FormPanel ID="FormPanel1" runat="server">
        <Items>
            <ext:TextField runat="server" AllowBlank="false" />
        </Items>
    </ext:FormPanel>

    <ext:Button runat="server" Text="Submit">
        <%--<Listeners>
            <Click Handler="return false;" /> it has the same effect as returning false from a DirectEvent's Before.
        </Listeners>--%>
        <DirectEvents>
            <Click OnEvent="Submit" Before="return App.FormPanel1.isValid();" />
        </DirectEvents>
    </ext:Button>
</form>


另一种方法是使用 。如果FormPanel无效,它会自动禁用组件。一个组件应属于FormPanel。

Another approach is using FormBind. It automatically disables a component if a FormPanel is invalid. A component should belong to a FormPanel.




Ext.NET v2示例



Ext.NET v2 Example

    <ext:FormPanel ID="FormPanel1" runat="server" Width="200">
        <Items>
            <ext:TextField runat="server" AllowBlank="false" />
        </Items>
        <Buttons>
            <ext:Button runat="server" Text="Submit" FormBind="true">
                <DirectEvents>
                    <Click OnEvent="Submit" />
                </DirectEvents>
            </ext:Button>
        </Buttons>
    </ext:FormPanel>
</form>


您可以收听FormPanel的事件来应用一些自定义操作。

You can listen a FormPanel's ValidityChange event to apply some custom actions.

这篇关于直接点击事件之前的表单验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 17:38