Feb 16, 2012, 1:32 PM
Set control validation after checkbox is checked
Hi,
How could I set a datefield control as a required field after a checkbox is checked and validate the form?
I've tried setting a listener on the check of the checkbox and then setting the AllowBlank property on the datefield.
Am I close to the solution, or is it not possible to do?
Thanks,
Example Code:
How could I set a datefield control as a required field after a checkbox is checked and validate the form?
I've tried setting a listener on the check of the checkbox and then setting the AllowBlank property on the datefield.
Am I close to the solution, or is it not possible to do?
Thanks,
Example Code:
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<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">
</ext:ResourceManager>
<ext:Window ID="Window1" runat="server" Modal="true" Height="300" Icon="Application" Title="Details" Width="700" Padding="10">
<Items>
<ext:FormPanel ID="Panel1" runat="server">
<Items>
<ext:Checkbox ID="chkResolved" FieldLabel="Resolved" runat="server">
<Listeners>
<Check Handler="if (#{chkResolved}.getValue() == true){#{dfResolved}.AllowBlank = false;}else{#{dfResolved}.AllowBlank = true;}" />
</Listeners>
</ext:Checkbox>
<ext:DateField ID="dfResolved" FieldLabel="Date Resolved" runat="server" BlankText="Date Required">
</ext:DateField>
</Items>
<BottomBar>
<ext:StatusBar runat="server">
<Plugins>
<ext:ValidationStatus runat="server" FormPanelID="Panel1" ValidIcon="Accept" ErrorIcon="Exclamation" />
</Plugins>
</ext:StatusBar>
</BottomBar>
</ext:FormPanel>
</Items>
<Buttons>
<ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
<DirectEvents>
<Click
Before="if (#{Panel1}.getForm().isValid()) {Ext.Msg.alert('Submit', 'Saved!');return #{Panel1}.getForm().isValid();}else{Ext.Msg.show({icon: Ext.MessageBox.ERROR, msg: 'You have missed out some information', buttons:Ext.Msg.OK});return #{Panel1}.getForm().isValid();}" />
</DirectEvents>
</ext:Button>
<ext:Button ID="btnCancel" runat="server" Text="Cancel" Icon="Cancel">
<Listeners>
<Click Handler="#{Window1}.hide();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Window>
</form>
</body>
</html>