[CLOSED] validation fail

  1. #1

    [CLOSED] validation fail

    hi,

    i am validating coolite textbox. if i enter wrong input in textbox, which shows error. Then i click the button, it fires, even there is errors in textbox. how to avoid button click fire event , if validation error occurs in textboxes.

    please see the code.


    
    
    
    <%@ Page Language="C#" %>
    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    
    <head id="Head1" runat="server">
    
    
    <script runat="server">
    
    
    
    
    
    protected void Button1_Click(object sender, AjaxEventArgs e)
    
    
    {
    
    
    TextField1.Text = "success"; 
    
    
    }
    
    
    
    
    
    </script>
    
    
    <title></title>
    
    
    </head>
    
    
    <body>
    
    
    <form id="form1" runat="server">
    
    
    <ext:ScriptManager ID="ScriptManager1" runat="server" /> 
    
    
    <ext:Panel ID="FormPanel" runat="server" Width="400" Height="400" Frame="true" Title="Form panel"> 
    
    
    <Body> 
    
    
    <ext:FormLayout ID="FormLayout1" runat="server"> 
    
    
    <ext:Anchor> 
    
    
    <ext:TextField ID="TextField1" runat="server" Regex="/^(\d{3}[-]?){1,2}(\d{4})$/" FieldLabel="Phone" RegexText="Not a valid phone number. Must be in the format 123-4567" > 
    
    
    </ext:TextField> 
    
    
    </ext:Anchor> 
    
    
    <ext:Anchor> 
    
    
    <ext:TextField ID="TextField2" runat="server" Regex="/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/" FieldLabel="Numeric" RegexText="Not a valid number" > 
    
    
    </ext:TextField> 
    
    
    </ext:Anchor> 
    
    
    <ext:Anchor> 
    
    
    <ext:TextField ID="TextField3" runat="server" Regex="/^[a-zA-Z_]+$/" FieldLabel="Alpha" RegexText="This field should only contain letters" > 
    
    
    </ext:TextField> 
    
    
    </ext:Anchor> 
    
    
    </ext:FormLayout> 
    
    
    </Body> 
    
    
    <Buttons> 
    
    
    <ext:Button ID="Button1" runat="server" Text="Validate"> 
    
    
    <Listeners> 
    
    
    <Click Handler="#{FormPanel}.items.each(function(item){item.validate();});" /> 
    
    
    </Listeners> 
    
    
    <AjaxEvents>
    
    
    <Click OnEvent="Button1_Click" ></Click>
    
    
    </AjaxEvents> 
    
    
    </ext:Button> 
    
    
    </Buttons> 
    
    
    </ext:Panel> 
    
    
    </form>
    
    
    </body>
    
    
    </html>
  2. #2

    RE: [CLOSED] validation fail


    Hi speedstemen4,

    you can try this code, it should be ok.

    
    <Click Handler=" 
    
    canSubmit = false; 
    
    #{FormPanel}.items.each( 
    
    function(item) { canSubmit = item.validate();  if(!canSubmit) breack;
    
    } 
    
    ); 
    
    return canSubmit;  " />

    Matteo
  3. #3

    RE: [CLOSED] validation fail

    Hi,

    AjaxEvent doesn't check any controls before request. You should check all conditions manually in listener and return false if need cancel request (as shown by Matteo in the previous post) or check conditions and return false in Before handler of AjaxEvent





Similar Threads

  1. [CLOSED] Ext.Net 2.0 - convert 1.2 version Ext.Net MVC fail
    By romeu in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Apr 02, 2012, 1:42 PM
  2. Replies: 3
    Last Post: Jul 11, 2011, 9:43 AM
  3. [CLOSED] [1.0] Stores fail with error
    By ljankowski in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Sep 02, 2010, 3:33 PM
  4. [CLOSED] validation Fail
    By majestic in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 05, 2009, 4:36 AM
  5. ScriptManager in 2.0 app Causes CSS to fail
    By Tbaseflug in forum Bugs
    Replies: 0
    Last Post: Apr 22, 2009, 1:52 PM

Posting Permissions