[CLOSED] FormPanel required field

  1. #1

    [CLOSED] FormPanel required field

    Hi
    I want to know how I can put red * caracter (*) on the field label for all required fields on a formpanel (allowblank=false)
    thanks,
  2. #2

    RE: [CLOSED] FormPanel required field

    Hi,

    Just use the following FieldLabel
    FieldLabel="Label(*)"
  3. #3

    RE: [CLOSED] FormPanel required field

    Hum!!!
    You are right but I want it automatically as soon as the AllowBlank property is set to true or false.
    thanks Vlad
  4. #4

    RE: [CLOSED] FormPanel required field

    Hi,
    Any Idea?
    Thanks
  5. #5

    RE: [CLOSED] FormPanel required field

    Hi,

    You can go over FormLayout controls (Anchors collection of FormLayout) and modify FieldLabel if AllowBlank="false".
  6. #6

    RE: [CLOSED] FormPanel required field

    Can you just add the logic when you're setting the field value?

    You could also inherit from the control inside your own custom Project/Namespace, then add logic to toggle the property.


    Hope this helps.


    Geoffrey McGill
    Founder
  7. #7

    RE: [CLOSED] FormPanel required field

    Hi,
    Something like this :

    
    
    
    <%@ Page Language="C#" %>
    
    
    <script runat="server">
    
    
    protected void Page_Load(object sender, EventArgs e)
    
    
    {
    
    
    if (!Ext.IsAjaxRequest)
    
    
    {
    
    
    SetRequiredFieldsInfos(FormLayout1);
    
    
    SetRequiredFieldsInfos(FormLayout2);
    
    
    }
    
    
    }
    
    
    
    
    
    public void SetRequiredFieldsInfos(FormLayout layout)
    
    
    {
    
    
    foreach (var item in layout.Anchors)
    
    
    {
    
    
    if (item.Items.Count > 0)
    
    
    {
    
    
    var field = item.Items[0] as TextFieldBase;
    
    
    if (field != null)
    
    
    {
    
    
    if (field.AllowBlank == false )
    
    
    field.FieldLabel = field.FieldLabel + "(*)";
    
    
    }
    
    
    }
    
    
    }
    
    
    }
    
    
    </script>
    
    
    <%@ 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">
    
    
    <title>FormPanel Validation - Coolite Toolkit Examples</title>
    
    
    <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    
    
    <style type="text/css">
    
    
    .icon-exclamation {
    
    
    padding-left: 25px !important;
    
    
    background: url(/icons/exclamation-png/coolite.axd) no-repeat 3px 3px !important;
    
    
    }
    
    
    .icon-accept {
    
    
    padding-left: 25px !important;
    
    
    background: url(/icons/accept-png/coolite.axd) no-repeat 3px 3px !important;
    
    
    }
    
    
    </style>
    
    
    </head>
    
    
    <body>
    
    
    <form id="form1" runat="server">
    
    
    <ext:ScriptManager runat="server" />
    
    
    
    
    
    <ext:FormPanel 
    
    
    ID="FormPanel1" 
    
    
    runat="server" 
    
    
    Title="FormPanel Validation (all fields required)"
    
    
    MonitorPoll="500" 
    
    
    MonitorValid="true" 
    
    
    Width="600" 
    
    
    BodyStyle="padding:5px;" 
    
    
    ButtonAlign="Right">
    
    
    <Body>
    
    
    <ext:ColumnLayout runat="server">
    
    
    <ext:LayoutColumn ColumnWidth=".5">
    
    
    <ext:Panel runat="server" Border="false" Header="false">
    
    
    <Body>
    
    
    <ext:FormLayout runat="server" LabelAlign="Top" ID="FormLayout1">
    
    
    <ext:Anchor Horizontal="92%">
    
    
    <ext:TextField ID="TextField1" runat="server" FieldLabel="First Name" AllowBlank="false" />
    
    
    </ext:Anchor>
    
    
    <ext:Anchor Horizontal="92%">
    
    
    <ext:TextField runat="server" FieldLabel="Company" AllowBlank="true" />
    
    
    </ext:Anchor>
    
    
    </ext:FormLayout>
    
    
    </Body>
    
    
    </ext:Panel>
    
    
    </ext:LayoutColumn>
    
    
    <ext:LayoutColumn ColumnWidth=".5">
    
    
    <ext:Panel runat="server" Border="false">
    
    
    
    
    
    <Body>
    
    
    <ext:FormLayout ID="FormLayout2" runat="server" LabelAlign="Top">
    
    
    <ext:Anchor Horizontal="92%">
    
    
    <ext:TextField runat="server" FieldLabel="Last Name" AllowBlank="false" />
    
    
    </ext:Anchor>
    
    
    <ext:Anchor Horizontal="92%">
    
    
    <ext:TextField runat="server" FieldLabel="Email" Vtype="email" AllowBlank="false" />
    
    
    </ext:Anchor>
    
    
    </ext:FormLayout>
    
    
    </Body>
    
    
    </ext:Panel>
    
    
    </ext:LayoutColumn>
    
    
    </ext:ColumnLayout>
    
    
    </Body>
    
    
    <Buttons>
    
    
    <ext:Button runat="server" Text="Save">
    
    
    <Listeners>
    
    
    <Click Handler="if(#{FormPanel1}.getForm().isValid()){Ext.Msg.alert('Submit', 'Saved!');}else{Ext.Msg.show({icon: Ext.MessageBox.ERROR, msg: 'FormPanel is incorrect', buttons:Ext.Msg.OK});}" />
    
    
    </Listeners>
    
    
    </ext:Button>
    
    
    <ext:Button runat="server" Text="Cancel" />
    
    
    </Buttons>
    
    
    <BottomBar>
    
    
    <ext:StatusBar ID="FormStatus" runat="server" />
    
    
    </BottomBar>
    
    
    <Listeners>
    
    
    <ClientValidation Handler="#{FormStatus}.setStatus({text: valid ? 'Form is valid' : 'Form is invalid', iconCls: valid ? 'icon-accept' : 'icon-exclamation'});" />
    
    
    </Listeners>
    
    
    </ext:FormPanel>
    
    
    </form>
    
    
    </body>
    
    
    </html>

Similar Threads

  1. Required Field Validation
    By t0ny in forum 1.x Help
    Replies: 10
    Last Post: Aug 25, 2014, 12:01 PM
  2. Replies: 3
    Last Post: Dec 29, 2012, 6:15 AM
  3. [CLOSED] MessageBox prompt with required field
    By jchau in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 23, 2012, 4:39 PM
  4. [CLOSED] TextField does not show the red borders for a required field.
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 16, 2010, 12:03 PM
  5. [CLOSED] JS required field validation before triggering AjaxEvent
    By bfolger in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Sep 15, 2009, 5:47 PM

Posting Permissions