[CLOSED] [0.8.2] CheckBox and Validator

  1. #1

    [CLOSED] [0.8.2] CheckBox and Validator

    Hi!
    I have form with 2 check boxes:

    
                                                    <ext:FormLayout ID="FormLayout4" runat="server" LabelAlign="Left" LabelWidth="160">
                                                        <ext:Anchor Horizontal="92%">
                                                            <ext:MultiField ID="MultiField2" runat="server" FieldLabel="Wybierz operację">
                                                                <Fields>
                                                                    <ext:Checkbox ID="checkBoxWydrukuj" runat="server" BoxLabel="Wydrukuj" Checked="true"
                                                                        Validator="validateWydrukWysylka" InvalidText="One of checkboxes has to be checked!." />
                                                                    <ext:Checkbox ID="checkBoxWyslij" runat="server" BoxLabel="Wyślij" Checked="true" 
                                                                    Validator="validateWydrukWysylka" InvalidText="One of checkboxes has to be checked!." />
                                                                </Fields>
                                                            </ext:MultiField>
                                                        </ext:Anchor>
                                                    </ext:FormLayout>
                                                </Body>
                                            </ext:Panel>
    my validator content:


     var validateWydrukWysylka = function() {
                alert('validator called');
                return checkBoxWydrukuj.getValue() || checkBoxWyslij.getValue();
            }
    but validator code never is called - and form is valid even if 2 checkboxes are blank....
    a piece of code:

    alert(#{checkBoxWydrukuj}.isValid()); var valid= #{FormPanel1}.getForm().isValid();
    always return true....
    Last edited by Daniil; Sep 10, 2010 at 11:22 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Checkbox class doesn't support Validator.
    Only TextField class (and extending this) supports.

    Please override the validateValue method of Checkboxes

    Example
    <%@ 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 runat="server">
        <title>Coolite 0.8.2 Example</title>
    
        <script type="text/javascript">
            var validateValue = function() {
                return Checkbox1.getValue() || Checkbox2.getValue();
            }
        </script>
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <ext:FormPanel 
            ID="FormPanel1" 
            runat="server" 
            Width="100" 
            Height="100" 
            HideLabels="true">
            <Body>
                <ext:FormLayout runat="server">
                    <ext:Anchor>
                        <ext:MultiField runat="server">
                            <Fields>
                                <ext:Checkbox ID="Checkbox1" runat="server" Checked="true">
                                    <CustomConfig>
                                        <ext:ConfigItem Name="validateValue" Value="validateValue" />
                                    </CustomConfig>
                                </ext:Checkbox>
                                <ext:Checkbox ID="Checkbox2" runat="server" Checked="true">
                                    <CustomConfig>
                                        <ext:ConfigItem Name="validateValue" Value="validateValue" />
                                    </CustomConfig>
                                </ext:Checkbox>
                            </Fields>
                        </ext:MultiField>
                    </ext:Anchor>
                </ext:FormLayout>
            </Body>
            <Buttons>
                <ext:Button runat="server" Text="Click me">
                    <Listeners>
                        <Click Handler="alert(#{FormPanel1}.isValid())" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:FormPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. Crazy validator
    By CarWise in forum Bugs
    Replies: 1
    Last Post: Jan 10, 2011, 10:41 AM
  2. [CLOSED] [8.2] How to change Validator method?
    By mrozik in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 18, 2010, 7:37 PM
  3. [CLOSED] textarea with validator
    By jeremyl in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 27, 2010, 10:09 AM
  4. [CLOSED] Custom validator for TextArea
    By shahidmughal in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 04, 2010, 7:05 PM
  5. Compare Validator
    By Rod in forum 1.x Help
    Replies: 0
    Last Post: Oct 30, 2008, 9:50 AM

Tags for this Thread

Posting Permissions