[CLOSED] Form is showing invalid at start

  1. #1

    [CLOSED] Form is showing invalid at start

    Hi,

    The FormPanel initially starts off showing as Invalid. But later it becomes all right. How do I set it to valid at start?

    Thanks

    Ravi Swaminathan
    Last edited by Baidaly; Mar 04, 2013 at 9:46 PM. Reason: [CLOSED]
  2. #2
    You can set the .ShowFormAsValidAtStart="true" property.

    Or, you can post a simplified code sample demonstrating how to reproduce what you're seeing and we will investigate further.
    Geoffrey McGill
    Founder
  3. #3

    Re: Form is showing invalid at start

    Hi Geoffrey,

    I could not find .ShowFormAsValidAtStart property in my FormPanel.

    In the actual code I am prepopulating my form with values from the grid. So, when the Form comes up the status bar says Form in Invalid, and the Save button is disabled. Only when I type something into each of the fields does the form become valid.

    The example below does not have a grid but I am pre-populating with values in the Page Load event. I could re-produce the first time I ran this sample code but not again.

    Thanks

    Ravi Swaminathan


    %@ Page Language="vb" AutoEventWireup="false" CodeBehind="FormValidationWithDataAlreadyPresent.aspx.vb" Inherits="EXTTabs.FormValidationWithDataAlreadyPresent" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        
    
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load           fpAddAuth_pAddAuth1_txtSSN.Text = "123456789"         fpAddAuth_pAddAuth1_txtSSN2.Text = "123456789"         txtFirstName.Text = "TEST"         txtMiddleName.Text = "TEST"         txtLastName.Text = "TEST"         dtStartDate.Value = "02/21/2013"         dtEndDate.Value = "02/21/2013"         End Sub     Protected Sub CheckField(sender As Object, e As Ext.Net.RemoteValidationEventArgs)             Dim strFieldName As String = String.Empty           Select Case sender.GetType().ToString()             Case "Ext.Net.TextField"                 strFieldName = DirectCast(sender, Ext.Net.TextField).ID             Case "Ext.Net.DateField"                 strFieldName = DirectCast(sender, Ext.Net.DateField).ID             Case "Ext.Net.ComboBox"                 strFieldName = DirectCast(sender, Ext.Net.ComboBox).ID             Case Else                 strFieldName = DirectCast(sender, Ext.Net.TextField).ID         End Select         e.Success = True           If strFieldName = "fpAddAuth_pAddAuth1_txtSSN2" Then             If Trim(fpAddAuth_pAddAuth1_txtSSN2.Text) <> Trim(fpAddAuth_pAddAuth1_txtSSN.Text) Then                 e.ErrorMessage = "SSN's do not match"                 e.Success = False                 Exit Sub             Else                 e.Success = True             End If         Else             e.Success = True         End If         End Sub
    </script>
    
    
    
    
    <!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 runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" DebugConsole="Ext" />
        <ext:Store ID="Store1" runat="server">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="cust-no" />
                        <ext:RecordField Name="name" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="5" Mode="Raw" />
            </AutoLoadParams>
        </ext:Store>
        <ext:FormPanel ID="fpAddAuth" runat="server" Border="false" MonitorValid="true" Padding="5"
            Width="675" Height="450" ButtonAlign="Right">
            <Items>
                <ext:FieldSet ID="fpAddAuth_pAddAuth1" runat="server" Border="true" Title="Donor Demographics"
                    Header="true" ColumnWidth=".5" Layout="FormLayout" Margins="5" Padding="5" LabelAlign="Left">
                    <Defaults>
                        <ext:Parameter Name="MsgTarget" Value="side" />
                    </Defaults>
                    <Items>
                        <ext:TextField ID="fpAddAuth_pAddAuth1_txtSSN" runat="server" FieldLabel="Donor ID"
                            MaxLength="10" AnchorHorizontal="45%" IsRemoteValidation="true" LabelAlign="Left"
                            AllowBlank="false" MaskRe="[0-9]">
                            <RemoteValidation OnValidation="CheckField" />
                        </ext:TextField>
                        <ext:Panel ID="pnlSSNSearch" runat="server" Border="false">
                            <Items>
                                <ext:ColumnLayout ID="CltSSNSearch" runat="server" Split="true" FitHeight="true"
                                    Margin="5">
                                    <Columns>
                                        <ext:LayoutColumn ColumnWidth=".48">
                                            <ext:Panel ID="pnlSSNReKey" runat="server" Border="false" Margins="0" Padding="0"
                                                Height="45">
                                                <Items>
                                                    <ext:TextField ID="fpAddAuth_pAddAuth1_txtSSN2" runat="server" FieldLabel="Re-key Donor ID"
                                                        MaxLength="10" Width="285" AnchorHorizontal="45%" LabelAlign="Left" AllowBlank="false"
                                                        IsRemoteValidation="true">
                                                        <RemoteValidation OnValidation="CheckField" />
                                                    </ext:TextField>
                                                </Items>
                                            </ext:Panel>
                                        </ext:LayoutColumn>
                                        <ext:LayoutColumn ColumnWidth=".20">
                                            <ext:Panel ID="pnlGetSSN" runat="server" Border="false" Margins="5" Padding="0" Height="35">
                                                <Items>
                                                    <ext:Button ID="btnSSNSearch" runat="server" Text="Go">
                                                    </ext:Button>
                                                </Items>
                                            </ext:Panel>
                                        </ext:LayoutColumn>
                                    </Columns>
                                </ext:ColumnLayout>
                            </Items>
                        </ext:Panel>
                        <ext:TextField ID="txtFirstName" runat="server" FieldLabel="First Name" MaxLength="35"
                            OnDirectSelect="DataHasChanged" AnchorHorizontal="92%" LabelAlign="Top" AllowBlank="false"
                            IsRemoteValidation="true">
                            <RemoteValidation OnValidation="CheckField" />
                        </ext:TextField>
                        <ext:TextField ID="txtMiddleName" runat="server" FieldLabel="Middle Name" MaxLength="35"
                            OnDirectSelect="DataHasChanged" AnchorHorizontal="92%" LabelAlign="Top" AllowBlank="true">
                        </ext:TextField>
                        <ext:TextField ID="txtLastName" runat="server" FieldLabel="Last Name" MaxLength="35"
                            OnDirectSelect="DataHasChanged" AnchorHorizontal="92%" LabelAlign="Top" AllowBlank="false"
                            IsRemoteValidation="true">
                            <RemoteValidation OnValidation="CheckField" />
                        </ext:TextField>
                    </Items>
                </ext:FieldSet>
                <ext:FieldSet ID="pAddAuth2" runat="server" Border="true" Title="NASAP Data" Layout="FormLayout"
                    ColumnWidth=".5" LabelAlign="Left">
                    <Defaults>
                        <ext:Parameter Name="AllowBlank" Value="false" Mode="Raw" />
                        <ext:Parameter Name="MsgTarget" Value="side" />
                    </Defaults>
                    <Items>
                        <ext:DateField ID="dtStartDate" runat="server" FieldLabel="Start Date" AnchorHorizontal="92%"
                            IsRemoteValidation="true" AllowBlank="false">
                            <RemoteValidation OnValidation="CheckField" ValidationEvent="change" EventOwner="Field"/>
                        </ext:DateField>
                        <ext:DateField ID="dtEndDate" runat="server" FieldLabel="End Date" AnchorHorizontal="92%"
                            IsRemoteValidation="true" AllowBlank="false">
                            <RemoteValidation OnValidation="CheckField" ValidationEvent="change" EventOwner="Field"/>
                        </ext:DateField>
                    </Items>
                </ext:FieldSet>
                
            </Items>
            <Buttons>
                <ext:Button ID="btnSaveAuthAdd" runat="server" Text="Save" FormBind="true" />
                <ext:Button ID="btnCloseAuthAdd" runat="server" Text="Close" FormBind="false">
                    <Listeners>
                        <Click Handler="#{fpAddAuth}.hide();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
            <BottomBar>
                <ext:StatusBar ID="StatusBar1" runat="server" Height="25" />
            </BottomBar>
            <Listeners>
                <ClientValidation Handler="this.getBottomToolbar().setStatus({text : valid ? 'Form is valid' : 'Form is invalid', iconCls: valid ? 'icon-accept' : 'icon-exclamation'});" />
            </Listeners>
        </ext:FormPanel>
        </form>
    </body>
    </html>
  4. #4
    It would be best if you could remove all code that is not directly related to the problem. Please minify down to the absolute minimum required to reproduce the problem.
    Geoffrey McGill
    Founder
  5. #5

    Re: Form is showing invalid at start

    Here is a simple example I have re-produced. When selecting a record from the grid, the two fields below in the Form Panel get populated with the selected record. However, the btnSave button remains disabled and the status bar says "Form is invalid".

    Thanks

    Ravi Swaminathan


    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="FormValidation.aspx.vb"
        Inherits="EXTTabs.FormValidation" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
         Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
            Me.Store1.DataSource = New Object() {New Object() {"12345", "ABC Ltd (12345)"}, New Object() {"5444", "XYZ Inc (5444)"}, New Object() {"67677", "Overseas Iron Works (67677)"}, New Object() {"234234", "Software Services(234234)"}, New Object() {"7765756", "Movie Zone(7765756)"}, New Object() {"76866", "Johnson Clips (76866)"}, _
    New Object() {"465464", "Sports House (465464)"}, New Object() {"57655", "Green House (57655)"}}
    
            Me.Store1.DataBind()
    
        End Sub
        Protected Sub CheckField(sender As Object, e As Ext.Net.RemoteValidationEventArgs)
    
            e.Success = True
    
        End Sub
        Protected Sub RowSelect(sender As Object, e As DirectEventArgs)
            Dim data As String = e.ExtraParams("Company")
            Dim results As New XmlDocument()
    
            results.LoadXml(String.Format("<record>{0}</record>", data))
    
            txtCustNo.Text = results("record").Item("custno").InnerText
            txtName.Text = results("record").Item("name").InnerText
        End Sub
    </script>
    
    
    <!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 runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" DebugConsole="Ext" />
        <ext:Store ID="Store1" runat="server">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="custno" />
                        <ext:RecordField Name="name" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>
            <AutoLoadParams>
                <ext:Parameter Name="start" Value="0" Mode="Raw" />
                <ext:Parameter Name="limit" Value="5" Mode="Raw" />
            </AutoLoadParams>
        </ext:Store>
        <ext:GridPanel ID="GridPanel1" runat="server" StripeRows="true" Title="Array Grid"
            TrackMouseOver="true" Width="600" Height="350" StoreID="Store1" AutoExpandColumn="name">
            <ColumnModel ID="ColumnModel1" runat="server">
                <Columns>
                    <ext:Column ColumnID="Company" Header="Company" DataIndex="custno" />
                    <ext:Column Header="name" DataIndex="name">
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
                    <DirectEvents>
                        <RowSelect OnEvent="RowSelect" Buffer="100">
                            <EventMask ShowMask="true" Target="CustomTarget" CustomTarget="#{fpCustomer}" />
                            <ExtraParams>
                                <%-- or can use params[2].id as value --%>
                                <ext:Parameter Name="Company" Value="this.getSelected().data" Mode="Raw" />
                            </ExtraParams>
                        </RowSelect>
                    </DirectEvents>
                </ext:RowSelectionModel>
            </SelectionModel>
        </ext:GridPanel>
        <ext:FormPanel ID="fpCustomer" runat="server" Border="false" MonitorValid="true"
            Padding="5" Width="500" Height="150" ButtonAlign="Right">
            <Items>
                <ext:TextField ID="txtCustNo" runat="server" FieldLabel="Customer Number" MaxLength="35"
                    AnchorHorizontal="92%" LabelAlign="Top" AllowBlank="false" IsRemoteValidation="true">
                    <RemoteValidation OnValidation="CheckField" />
                </ext:TextField>
                <ext:TextField ID="txtName" runat="server" FieldLabel="Customer Name" MaxLength="35"
                    IsRemoteValidation="true" AnchorHorizontal="92%" LabelAlign="Top" AllowBlank="true">
                    <RemoteValidation OnValidation="CheckField" />
                </ext:TextField>
            </Items>
            <Buttons>
                <ext:Button ID="btnSave" runat="server" Text="Save" FormBind="true" />
                <ext:Button ID="btnClose" runat="server" Text="Close" FormBind="false">
                    <Listeners>
                        <Click Handler="#{fpCustomer}.hide();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
            <BottomBar>
                <ext:StatusBar ID="StatusBar1" runat="server" Height="25" />
            </BottomBar>
            <Listeners>
                <ClientValidation Handler="this.getBottomToolbar().setStatus({text : valid ? 'Form is valid' : 'Form is invalid', iconCls: valid ? 'icon-accept' : 'icon-exclamation'});" />
            </Listeners>
        </ext:FormPanel>
        </form>
    </body>
    </html>
  6. #6
    Hello!

    Try the following:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    	If Not Ext.Net.X.IsAjaxRequest Then
    	Me.Store1.DataSource = New Object() {New Object() {"12345", "ABC Ltd (12345)"}, New Object() {"5444", "XYZ Inc (5444)"}, New Object() {"67677", "Overseas Iron Works (67677)"}, New Object() {"234234", "Software Services(234234)"}, New Object() {"7765756", "Movie Zone(7765756)"}, New Object() {"76866", "Johnson Clips (76866)"}, _
    		New Object() {"465464", "Sports House (465464)"}, New Object() {"57655", "Green House (57655)"}}
    
    	Me.Store1.DataBind()
    	End If
    End Sub
    Protected Sub CheckField(sender As Object, e As Ext.Net.RemoteValidationEventArgs)
    
    	e.Success = True
    
    End Sub
    Protected Sub RowSelect(sender As Object, e As DirectEventArgs)
    	Dim data As String = e.ExtraParams("Company")
    	Dim results As New XmlDocument()
    
    	results.LoadXml(String.Format("<record>{0}</record>", data))
    
    	txtCustNo.SetValue(results("record").Item("custno").InnerText)
    	txtName.SetValue(results("record").Item("name").InnerText)
    	txtCustNo.Call("remoteValidate")
    	txtName.Call("remoteValidate")
    End Sub
  7. #7

    Re: Form is showing invalid at start

    Thanks. The sample works fine.

    However, within my actual application which has more fields, like date and combo, the form still shows invalid.

    Is there a way to forcibly set the form as valid when I select a record from the grid?

    Thanks

    Ravi Swaminathan
  8. #8

    Re: Form is showing invalid at start

    I found out what the issue was. In one of my textfields there was no remote validation, but had the AllowBlank property set to false. When I set it to true the form validation worked as expected.

    Thanks for your help. Kindly close this case.

    Ravi Swaminathan

Similar Threads

  1. Replies: 4
    Last Post: Apr 30, 2012, 4:49 PM
  2. [CLOSED] cross-window form validation with focus on an invalid control
    By ViniVidi in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 18, 2011, 4:51 PM
  3. [CLOSED] Trying to flag a form as invalid
    By ewgoforth in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 09, 2011, 6:55 PM
  4. [CLOSED] Items not showing as part of Ext.form.CompositeField
    By joeRobee in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 10, 2010, 7:27 PM
  5. Replies: 6
    Last Post: May 25, 2010, 9:53 AM

Posting Permissions